Analysis of SOLR facet with source code

Source: Internet
Author: User
Tags solr
Searchhandler implements solrrequesthandler and solrcoreaware (inform interface). During solrcore initialization, the inform (solrcore core) in solrrequesthandler is called sequentially. In the inform call, the Components Object in searchhandler is initialized, component Objects include querycomponent, facetcomponent, and highlightcomponent. querycomponent is mainly used for query, and facetcomponent processes facet and highlightcomponent for highlighted display. In the Query Process, the component chain is called sequentially according to the component configuration in searchhandler. Searchhandler. in the implementation of handlerequestbody (solrqueryrequest req, solrqueryresponse RSP), The prepare, process, and distributedprocess methods of component are called, and solrindexsearcher in querycomponent is called. solrindexsearcher inherits the indexsearcher category. SOLR facetcomponent implements term-level statistics. This chapter focuses on the facetcomponent component in SOLR. Querycomponent first processes queries in the Q parameter. The docid of the query result is saved in docset. Here is a set of unordered document IDs. It encapsulates docset in simplefacets in facetcomponent. in the process method, simplefacets is called. getfacetcounts () obtains statistical results. Three types of results are returned to the client: facet_queries, facet_fields, facet_dates, and facet_ranges, we use facet_fieds Statistics (the query parameters include facet. filed = xxx, which can contain multiple facet. field), facet_filed statistics will eventually call simplefacets. gettermcounts (field), in this method implementation, according to facet. value of the method parameter
For different calls. Facet. method usually contains two values: enmu and FC. The default value is FC. This field represents the two statistical algorithms of facet. Enum calculates facet count by traversing the field's terms. For details, see the code in simplefacets, counts = getfacettermenumcounts (searcher, Docs, field, offset, limit, mincount, missing, sort, prefix ); enum is applicable when the field value is small. SOLR traverses all the values of this field, allocates a filter for each value from filtercache, and calculates the intersection between each filter and the primary query. FC (filed cache) traverses the document and searches for the value in the cache in the document. If it is found, add the value in the cache to 1. See the code in simplefacets. uninvertedfield UIF = uninvertedfield. getuninvertedfield (field, Searcher );
Counts = UIF. getcounts (searcher, Docs, offset, limit, mincount, missing, sort, prefix); facetcomponent uses fieldvaluecache based on a field, and the key is facet. field value, value is uninvertedfield,
The uninvertedfield class is mainly responsible for completing the frequency of each word term in the field and the word term in all documents, that is, the number of occurrences. Saved in an array, the created uninvertedfield is saved in the fieldvaluecache cache. After uninvertedfield is obtained, the uninvertedfield getcounts method is called to intersection the queried Document ID, if it is not the Document ID of the query result, the number of words in the field is 0. In addition, the words in the field are sorted, the facetcomponet of SOLR has two sorting options: Count and index. Count indicates the number of times each word appears, and index indicates the word dictionary order. If facet. sort is not specified for the query parameter, SOLR is sorted by count by default.

 

 

 

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.