- Lucene - Sorting
- Lucene - Analysis
- Lucene - Query Programming
- Lucene - Search Operation
- Lucene - Indexing Operations
- Lucene - Indexing Process
- Lucene - Searching Classes
- Lucene - Indexing Classes
- Lucene - First Application
- Lucene - Environment Setup
- Lucene - Overview
- Lucene - Home
Lucene Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Lucene - Query Programming
We have seen in previous chapter Lucene - Search Operation, Lucene uses IndexSearcher to make searches and it uses the Query object created by QueryParser as the input. In this chapter, we are going to discuss various types of Query objects and the different ways to create them programmatically. Creating different types of Query object gives control on the kind of search to be made.
Consider a case of Advanced Search, provided by many apppcations where users are given multiple options to confine the search results. By Query programming, we can achieve the same very easily.
Following is the pst of Query types that we ll discuss in due course.
S.No. | Class & Description |
---|---|
1 | This class acts as a core component which creates/updates indexes during the indexing process. |
2 | TermRangeQuery is used when a range of textual terms are to be searched. |
3 | PrefixQuery is used to match documents whose index starts with a specified string. |
4 | BooleanQuery is used to search documents which are result of multiple queries using AND, OR or NOT operators. |
5 | Phrase query is used to search documents which contain a particular sequence of terms. |
6 | WildcardQuery is used to search documents using wildcards pke * for any character sequence,? matching a single character. |
7 | FuzzyQuery is used to search documents using fuzzy implementation that is an approximate search based on the edit distance algorithm. |
8 | MatchAllDocsQuery as the name suggests matches all the documents. |