Recently I downloaded apache lucene project and struggled to run their examples. Probably this blog my help you to save 3hr of effort.
Aim: if you want to search a word inside the files. Please follow below steps
1. Index the directory first
2. Create a query file
3. Search the directory
• Indexing the dir ‘workspace’
o java -cp lucene-core-3.0.2.jar;lucene-demos-3.0.2.jar org.apache.lucene.demo.IndexFiles C:\workspace
• Create a query file “queries.txt” and save all the keys you want to search. For Example ‘hello’
o Search for ‘hello’ word in all the files under dir ‘workspace’
• Search using lucene
o java -cp lucene-core-3.0.2.jar;lucene-demos-3.0.2.jar org.apache.lucene.demo.SearchFiles -index C:\index C:\ queries.txt
queries.txt file should have string ‘hello’. If you want to search multiple words have multiple words in the file separated by \n