Apache Lucene - Building and Installing the Basic Demo
About this Document
This document is intended as a "getting started" guide to using and running the Lucene demos. It walks you through some basic installation and configuration.
About the Demos
The Lucene command-line demo code consists of two applications that demonstrate various functionalities of Lucene and how one should go about adding Lucene to their applications.
Setting your CLASSPATH
First, you should download the latest Lucene distribution and then extract it to a working directory. Alternatively, you can check out the sources from Subversion, and then run ant war-demo to generate the JARs and WARs.
You should see the Lucene JAR file in the directory you created when you extracted the archive. It should be named something like lucene-core-{version}.jar. You should also see a file called lucene-demos-{version}.jar. If you checked out the sources from Subversion then the JARs are located under the build subdirectory (after running ant successfully). Put both of these files in your Java CLASSPATH.
Indexing Files
Once you've gotten this far you're probably itching to go. Let's build an index! Assuming you've set your CLASSPATH correctly, just type:
java org.apache.lucene.demo.IndexFiles {full-path-to-lucene}/srcThis will produce a subdirectory called index which will contain an index of all of the Lucene source code.
To search the index type:
java org.apache.lucene.demo.SearchFilesYou'll be prompted for a query. Type in a swear word and press the enter key. You'll see that the Lucene developers are very well mannered and get no results. Now try entering the word "string". That should return a whole bunch of documents. The results will page at every tenth result and ask you whether you want more results.