Searching indexed data with Apache Lucene
Now that you have indexed your data, you will be searching the data using Apache Lucene in this recipe. The code for searching in this recipe depends on the index that you created in the previous recipe, and therefore, it will only successfully execute if you followed the instructions in the previous recipe.
Getting ready
- Complete the previous recipe. After completing the previous recipe, go to the index directory in your project that you created in step 11 of that recipe. Make sure that you see some indexing files there:
- Create a Java file named
SearchFiles
in theorg.apache.lucene.demo
package you created in the previous recipe: - Now you are ready to type in some code in the
SearchFiles.java
file.
How to do it...
- Open
SearchFiles.java
in the editor of Eclipse and create the following class:public class SearchFiles {
- You need to create two constant String variables. The first variable will contain the path of your
index
that you created...