The query object in Lucene

Source: Internet
Author: User

"Query object in Lucene":

Before retrieving, the retrieval string needs to be parsed, which is done by Queryparser. To ensure the correctness of the query, it is best to use the same parser when creating the index file. Queryparser You can specify a query field when parsing a string, you can actually specify one or more domains in a string. For example: "INFO: TV station and id:3329", "INFO: TV station", "TV station", if you do not specify a default domain, it will be queried in the default domain.

Queryparser calls the static method after parse returns an instance of query, an atomic lookup. For example: "INFO: TV station and id:3329" will return to Booleanquery, "INFO: TV" or "TV station" will return to Phrasequery, "Taiwan" will return to Termquery.

Lucene built-in query object:

Termquery: Entry query. By specifying a term, all documents that have the entry in the index are retrieved.

Booleanquery: Boolean query. Lucene contains logical relationships: Complex Queries "and", "or", "non", which are eventually represented as booleanquery. A Boolean query is a query made up of Boolean logic that consists of multiple clauses and clauses.

Rangequery: Range query. This range can be date, time, number, size, and so on.

Prefixquery: Prefix query.

Phrasequery: Phrase query. The default is an exact match, but you can specify a slope (slop, default of 0) to change the range. such as slop=1, the search phrase "Radio", then the "Radio" in the middle of a word can also be found out, such as "TV station."

Multiphrasequery: Multi-phrase query.

Fuquery: Fuzzy query. The matching algorithm used in fuzzy query is Levenshitein algorithm. When the algorithm compares two strings, the action is divided

This article from: Macaidong Blog Reprint please specify the source URL: http://www.makaidong.com

For 3 kinds: Add one letter (insert), delete one letter (delete), change one letter (substitute).

Wildcardquery: Wildcard query. The "*" number represents 0 to more characters, "? "Represents a single character.

Spanquery: Span query. This class is an abstract class.

Spantermquery: The retrieval effect is exactly the same as termquery, but some location information is recorded internally for use by other Spanquery APIs, which is the basis for other spanquery query.

Spanfirstquery: Finds the specified entry in a fixed width, starting at the start of the field's content.

Spannearquery: Functions similar to pharasequery. Spannearquery lookups are not necessarily phrases that match, but may also be the result of another spanquery query that is considered as a whole, nested queries.

Spanorquery: Combine all the spanquery query results as a result of the search.

Spannotquery: From the first spanquery query result, the second spanquery query result is removed as the result of the search.

Booleanclause classes used to represent Boolean query clause relationships, including: Booleanclause.occur.must,booleanclause.occur.must_not, Booleanclause.occur.should. There are 6 combinations of the following:

1. Must and must: Gets the intersection of a query clause.

2. Must and Must_not: indicates that the query results cannot contain the results of the query clause that the must_not corresponds to.

3. Must_not and Must_not: no meaning, no results are retrieved.

4. Should with must, should and must_not:should with must, the result is the result of the MUST clause. With Must_not, the function is the same as must.

5. Should and should: represents a "or" relationship, and the final result is a set of all the search clauses

The query object in Lucene

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.