October 13, 2010
At AboutUs where I work we recently re-implemented the
site’s search feature. Behind the scenes the new search uses
Sphinx (a super-fast and scalable search engine) and
Thinking Sphinx (which allows easy
configuration and querying of Sphinx from within Rails).
One thing that makes Sphinx so much faster than alternatives like Solr is that
it communicates directly with your database when it is building its search
index. This is far faster than talking with your application layer, and
indexing the result of your application models’ methods. In our case we’re
able to reindex about 40 million records in around 4 hours. Solr used to take
days.
Tagged with: search |
September 08, 2009
One of the handiest tools in my programming toolkit is ack, a Perl script that is great for searching through code (or really any text files). I use it a lot while refactoring, for example when I want to rename a method every time it’s called in a project.
You can install
ack with this command (from
http://betterthangrep.com/):
$curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 ~/bin/ack
Assuming that ~/bin/ack is in your path searching code is as easy as this:
$ ack my_poorly_named_method
Tagged with: search |
June 17, 2009
Here’s a really simple method for creating an instant search for a list of items. It lets you quickly filter a long list or table down to the few items you’re looking for.
First here’s a demo.
What’s nice is this only takes a few lines of code (and the magic of jQuery.)
$().ready(function(){
// Instant Search
$('#q').keyup(function(){
$('.search_item').each(function(){
var re = new RegExp($('#q').val(), 'i')
if($(this).children('.search_text')[0].innerHTML.match(re)){
$(this).show();
}else{
$(this).hide();
};
});
});
});
Tagged with: search |