Call us Toll-Free:
Live ChatEmail us


How to install and use CLucene

Michel Nadeau, 12-01-2008
For a recent project, we needed a fast and reliable indexing system. In the past, we tried Google Mini server: it's not bad, but it's not perfect - and with all the open source projects out there, it's too expensive for what you get.

After some researches, we found Lucene, a free indexing system made by Apache. It seems perfect and it's used by major sites like Digg and TypePad. Lucene is different from Google Mini and other indexing systems: Google Mini indexes your web server HTML files output, whereas Lucene allows for much higher granularity by letting you decide what goes into the index.

But - Lucene has some problems (for us):

* It's 100% Java
* It needs Apache Tomcat (Java servlet)
* It needs the Java SDK

First we're really no big fans of Java. Also, we run Nginx, not Apache, so switching to Apache and/or Apache Tomcat wasn't really a good plan for us. And as we like clean, minimalistic setups, running Nginx + Apache + Apache Tomcat + Java SDK + a Java application was definitely not a "comfortable" option.

And then we found CLucene - a C++ port of Lucene. CLucene has no crawler, no user interface, no daemon - we would describe it more as an API than as an "engine". You install it and then you build your own C++ wrapper using their libraries. If you wish you can also use an already existing PHP or Perl wrapper - but they're not really up-to-date: building your own C++ wrapper is definitely a better idea.

Installing CLucene is very easy and straightforward:

1. Download CLucene

Obtain CLucene like this:


2. Extract CLucene

Then extract CLucene like this:

tar xvfz clucene-core-0.9.21b.tar.gz

3. Configure CLucene

Then configure CLucene like this:

cd clucene-core-0.9.21b

4. Compile CLucene

Then compile CLucene like this:


5. Install CLucene

Finally, install CLucene like this:

make install

6. Using CLucene

The first experiment we did with CLucene was with the demo supplied with the source (clucene-core-0.9.21b/src/demo). After "making" the CLucene source, change to the "demo" directory and do a "make". Then you will be able to run "cl_demo" and see the basic features of CLucene: insert, search, delete.

We didn't use any PHP or Perl wrapper - we did our own C++ wrapper so we only know how to use CLucene in C++. To get started, we highly recommend that you download this post's attachment ( and extract it in clucene-core-0.9.21b/src/demo (replacing all files) and do a "make". It's basically doing the same thing that the CLucene's stock demo, just with a lot less of code and easier to understand (see Main.cpp).


CLucene is very simple, super-fast and a lot easier to install/use than Lucene (or any other indexing system). As it's an API, you can customize it as you want and you can easily move it from one server to another - we are definitely new fans of CLucene!

The only downside is that you have to create your own C++ (or other language) wrapper.
Attached Files
File Type: zip (17.1 KB, 3795 views)

Rob Young, 12-06-2008
Nice post Micheal, thanks. Just a few points, you don't need a servlet container (Tomcat) to use Java Lucene, it is just a library like CLucene. The usual architecture is to have to search server on a completely separate machine (or cluster if you're big) and exposing a web service interface to the rest of your application. In which case, having a divergent technology stack becomes slightly less of a concern.

Caner, 12-17-2008
Try using Sphinx if you want an indexing system for PHP. It is easy to setup, configure and use. Also it works fast.

Adrian Singer, 12-17-2008
Thank you Caner!

We did look into Sphinx but found it inferior to Lucene. Yes it is easier to setup but not as flexible.

More information about how Sphinx compares to Lucene can be found here:

web development, 02-09-2009
please contact me

Ariel, 02-18-2009
The link doesn't work, could post an active link ???

Adrian Singer, 02-18-2009
Hi Ariel,

Please try again - the attachment link is now working.

Thank you for the heads up!

hqlong, 07-29-2009
thank you!!

Machindra Dharmadhikari, 04-28-2011, this link is not working..

Machindra Dharmadhikari, 04-29-2011
Hi Adrian, this link is not working, can u plz active it??

Naveen, 03-20-2012
If you don't mind can you please share the prebuilt Clucene for VS 9 2008. Because we are having a hard time building the Clucene.

Thank you.

Laputa, 05-09-2012
I'm not a big fan of Java your post is very useful. thank you :)

clucene_user, 11-22-2014
I'm new in Clucene your post interest me. so I want to try your example but the link not working, can u plz active it?
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

Post your comments

Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.

About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions