Apache Lucene Installation and example


Apache Lucene is high performance open source search engine based on full-featured text searching

It is based on Java language and cross platform

It provided high performance searching with high-performance indexing functionality

Apache Lucene runs on Java 7 or greater

You check system requirements through the following
https://lucene.apache.org/core/5_1_0/SYSTEM_REQUIREMENTS.html

Apache Lucene’s documentation
https://lucene.apache.org/core/5_1_0/index.html

This tutorial is based on lucene-core-5.1.0 version
Go to http://apache.mirror1.spango.com/lucene/java/5.1.0/

Download lucene-5.1.0.zip

In order to use Lucene we need to put the following jars into CLASSPATH
lucene-core-5.1.0. jar.
lucene-queryparser-5.1.0.jar,
lucene-analyzers-common-5.1.0.jar
lucene-demo-5.1.0.jar

set LUCENE=C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0
java -cp %LUCENE%\core\lucene-core-5.1.0.jar;%LUCENE%\demo\lucene-demo-5.1.0.jar;%LUCENE%\queryparser\lucene-queryparser-5.1.0.jar;%LUCENE%\analysis\common\lucene-analyzers-common-5.1.0.jar org.apache.lucene.demo.IndexFiles -docs C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0

adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\httpcore-4.3.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\javax.servlet-3.0.0.v201112011016.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\jetty-continuation-8.1.10.v20130312.ja
r
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\jetty-http-8.1.10.v20130312.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\jetty-io-8.1.10.v20130312.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\jetty-server-8.1.10.v20130312.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\jetty-servlet-8.1.10.v20130312.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lib\jetty-util-8.1.10.v20130312.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\replicator\lucene-replicator-5.1.0.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\sandbox\lib\jakarta-regexp-1.4.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\sandbox\lucene-sandbox-5.1.0.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\spatial\lib\spatial4j-0.4.1.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\spatial\lucene-spatial-5.1.0.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\suggest\lucene-suggest-5.1.0.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\SYSTEM_REQUIREMENTS.txt
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\test-framework\lib\ant-1.8.2.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\test-framework\lib\junit-4.10.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\test-framework\lib\junit4-ant-2.1.12.jar
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\test-framework\lib\randomizedtesting-runner-2.1.12.ja
r
adding C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\test-framework\lucene-test-framework-5.1.0.jar
48688 total milliseconds

After indexing with Lucene you can use the following code in order to search 
java -cp %LUCENE%\core\lucene-core-5.1.0.jar;%LUCENE%\demo\lucene-demo-5.1.0.jar;%LUCENE%\queryparser\lucene-queryparser-5.1.0.jar;%LUCENE%\analysis\common\lucene-analyzers-common-5.1.0.jar org.apache.lucene.demo.SearchFiles

C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\demo>java -cp %LUCENE%\core\lucene-core-5.1.0.jar;%LUCENE%\d
emo\lucene-demo-5.1.0.jar;%LUCENE%\queryparser\lucene-queryparser-5.1.0.jar;%LUCENE%\analysis\common\lucene-an
alyzers-common-5.1.0.jar org.apache.lucene.demo.SearchFiles
Enter query:
test
Searching for: test
186 total matching documents
1. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\licenses\commons-codec-NOTICE.txt
2. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\analysis\README.txt
3. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\queryparser\docs\xml\README.htm
4. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\benchmark\README.enwiki
5. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\docs\benchmark\org\apache\lucene\benchmark\byTask\program
matic\package-summary.html
6. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\docs\test-framework\org\apache\lucene\util\BaseBitSetTest
Case.html
7. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\docs\test-framework\org\apache\lucene\util\package-summar
y.html
8. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\queryparser\docs\surround\README.txt
9. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\docs\classification\org\apache\lucene\classification\util
s\DatasetSplitter.html
10. C:\Users\tunato\Desktop\lucene-5.1.0\lucene-5.1.0\docs\test-framework\overview-summary.html
Press (n)ext page, (q)uit or enter number to jump to a page.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s