Lucene Sorting - Lucene

What is Lucene Sorting?

In this division, we will look interested in the sorting preparation in which Lucerne gives the search results by default or can be manipulate as essential.

Sorting by Relevance

This is the defaulting sorting mode used by Lucerne. Lucerne provides results by the most related hit at the top.

Sorting by Index Order

This sorting mode is used by Lucerne. Here, the initial document indexed is exposed first in the search result.

Example Application

Let us create a test Lucerne application to test the sorting procedure.

Step Description
1
Create a project with a nameLuceneFirstApplicationunder a packagecom.wisdomjobs.luceneas explained in theLucene - First Applicationchapter. You can also use the project created inLucene - First Applicationchapter as such for this chapter to understand the searching process.
2
CreateLuceneConstants.javaandSearcher.javaas explained in theLucene - First Applicationchapter. Keep the rest of the files unchanged.
3
CreateLuceneTester.javaas mentioned below.
4
Clean and Build the application to make sure the business logic is working as per the requirements.

LuceneConstants.java

This class is used to present different constants to be used diagonally the model application.

Searcher.java

This class is used to study the indexes made on raw data and searches data using the Lucerne documents.

LuceneTester.java

This class is used to analysis the searching capacity of the Lucerne library.

Data & Index Directory Creation

We have used 10 text files from record1.txt to record10.txt contain names and other information of the students and put them in the directory E:\Lucene\Data. Test Data. An index list path should be formed as E:\Lucene\Index. After administration the indexing program in the section Lucerne - Indexing Process, you can observe the list of index records created in that folder.

Running the Program

Formerly you are done with the construction of the source, the raw data, the data directory, the index list and the indexes, you can accumulate and run your program. To do this, maintain the LuceneTester.Java file tab active and use either the Run option presented in the Eclipse IDE or use Ctrl + F11 to compile and run your LuceneTester request. If your application runs successfully, it will issue the following message in Eclipse IDE's comfort –

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Lucene Topics