Termquery & filterquery

Source: Internet
Author: User
Tags idf

Termquery rewrite = this "wdx"
1. getweight Process
Instantiate a termweight with the following attributes:
Float value-IDF * boost/Math. SQRT (IDF * boost * IDF * boost)
Float IDF-term in index IDF
Float querynorm-1.0/Math. SQRT (IDF * boost * IDF * boost)
Float queryweight-IDF * boost/Math. SQRT (IDF * boost * IDF * boost)
--------------------------------------------
2. Construct the termscorer. scorer Process
A. Obtain the termdocs of the term, and obtain the documents in which the term appears, and the frequency of occurrence.
B. Obtain the norm of the doc CONTAINED IN THE indexreader in this field.
C. Use the data obtained by a. B to instantiate a termscorer.
--------------------------------------------
3. The next step is driven by scorer. Score (collector). termscorer implements the score (collector) and
The nextdoc, docid, and advance functions of the docidsetiterator object
A. nextdoc Function
Termscorer does not read termdocs one by one. It uses the READ function of termdocs to read 32 docids & freq in advance.
Put into the buffer zone. When nextdoc is called each time, the buffer zone is not initialized or the data in the buffer zone is used up, the read will be used to fill the buffer.
Buffer, the buffer has a cursor pointer, each time the buffer is filled, the cursor is set to 0; if there is data in the buffer, the cursor moves right, the current
Write docid & freq to the global variable Doc & freq
B. The doc function returns the global variable Doc.
C. Score Function compute the score of the current Doc
Termscorer calculates freq's score in addition to norm in [1-32] Doc in advance, because Norm's data related to each document
In this way, when the score of the current document is calculated, if freq is in the range of [1-32], it is directly in this array to retrieve ....
The formula for calculating the score is
Weight. Value * Math. SQRT (freq) * norm [docid]
-> Math. SQRT (freq) * norm [docid] * IDF * boost/Math. SQRT (IDF * boost * IDF * boost)
D. Score (collector) Function
Similar to nextdoc, nextdoc only takes one Doc at a time, and score (collector) gives all docids to collector at a time.
Call read cyclically to send the read docid to collector...

--------------------------------------------

filterquery
filterquery-{query, filter} rewrite = {query. rewrite, filter}
An anonymous class of weight of filterquery, within weight construction, weight & similarity of query is obtained.
then, weight Abstract Functions are implemented in the anonymous class.
-sumofsquaredweights calls query. weight. sumofsquaredweights * boost
-Normalize calls query. weight. normalize
-getvalue returns query. weight. getvalue * boost
-score returns an anonymous scorer, which is implemented as
first calling query. weight. scorer obtains the scorer of the original query and then obtains the filter. getdocidset
If the obtained docidset or docidsetiterator is null, null is returned.
eclipsetiterator stream}
if the current docid of the two docid streams is consistent, the current Doc is used.
-advance function, the preceding difference is that the two streams are first located based on the docid In the parameter, and then the above logic
-scorer function-returns scorer. score * boost

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.