Observation: Lucene rocks
I've wanted to figure out Lucene but never got around to it (the Lucene book is very outdated and none of the example code works, for instance) but today I did something simpler, a little experiment in indexing.
I have a directory of about 3.2 GB of XML documents (medical journal papers downloaded from ftp://ftp.ncbi.nlm.nih.gov/pub/pmc/articles.tar.gz -- it's about a 700 MB file). I wondered how long it would take the simple disk-based Lucene demo using default settings (http://lucene.apache.org/java/2_3_1/demo.html).
System stats: 7200 RPM 300 GB disk; Windows XP SP 2, Quad Core 2.4 ghz Core 2, 2 GB DDR2-800 RAM.
It took 23 minutes, the last 5 of which were merely flattening index chunks into a single file so that searches run faster.
So about 20 minutes for 3 gigs of text. The final index file was about 1/5 the size of the original source text at 646 MB.
Memory usage was very reasonable - it hovered around 30-40 MB (unlike, say, Java IDEs which use up 200 MB or so).
Ultimately a benchmark like this is disk-bound, but that's still fast as shit in my opinion. I had to whip together a ghetto homegrown indexing system at work several months ago (I've never had time to optimize it), and this blows away what I created.
14 comments
[ 23.2 ms ] story [ 219 ms ] threadI think for 10,000 documents (two fields: name and id) it takes 20 seconds to build the index in Lucene .NET.
I had always heard of using Lucene for really large datasets and thought it might be overkill for speeding up a somewhat small part of one application dialog. In reality it took a single reference to the Lucene .NET dll and a few functions to build the documents and add them to the index.
For our tests, it indexed much faster than the common Lucene implementations, and for our needs was also a tad faster overall. I haven't tried the newest version, though.
I think of Lucene as more implementor-neutral than Sphinx; Lucene is an API as well as a Java library.
Cutting's a genius.
It was also ridiculously easy to get Sphinx up and going. Lucene is a killer engine, no doubt, but Sphinx's ROI alone won us over.
The longest part of the process was trying to figure out which versions of Java Lucene and Zend PHP Lucene were compatible. FYI:
Lucene 2.1 index format support (which is also used in Lucene 2.2) is included in the current "trunk" branch. It is available via SVN in current nightly snapshots.
We hope to include Lucene 2.1 index format support in ZF 1.5.0. The current release (ZF V1.0.4) works with Lucene 1.9-2.0 index formats.
http://framework.zend.com/manual/en/zend.search.lucene.html#...
http://search.cpan.org/~tmtm/Plucene-1.21/lib/Plucene.pm
You better use Kinoseach, which also uses the same index format as lucene.
Some benchmarks are on this site : http://marvinhumphrey.com/kinosearch/benchmarks.html
http://xapian.org/