Author: Fighting nation is doing
Please indicate the address for reprint: http://www.cnblogs.com/prayers/p/8822417.html
Facet
Straight to the point, what facet solves is screening, which I understand as a kind of aggregation.
For example, brand name in product attributes. For example: the search recalls 100 sku, and these 100 sku are included in 20 brands, so how do I aggregate these 20 brands? Solr provides us with a powerful API, facet, the basic use cases are as follows
http://localhost:8080/solr/b2b/select?q=*:*&wt=json&indent=true&facet=true&facet.field=brandName
It should be noted here that if brandName is configured with a tokenizer, the result of facet is to group and count each unique word obtained after tokenizing the domain value of the domain.
Facet can not only support group statistics of single-valued fields, but also support statistics of multi-valued fields, text fields, and embedded facet. It should be noted that a large number of noise words will affect the results you return when performing facet in the text field. At this time, you need to configure a stop word filter for the text field.
There is another situation, such as brand name, I need to query for word segmentation and facet statistics. But the result of facet after word segmentation is not what I want, what I want is the result of facet without word segmentation. At this time, we can use the copy field CopyField, the brand name as a new field, and the type of the field is StringFilter. The use case of copyField is as follows:
<copyField source="brandName" dest="copyBrandName" maxChars="30000" />
source: the domain name to be copied
dest: the copied domain name
maxChars: limit the number of characters copied
The facet use case for a single domain is as follows
http://localhost:8080/solr/b2b/select?q=*:*&wt=json&indent=true&facet=true&facet.field=brandName
The facet use case for multiple domains is as follows
http://localhost:8080/solr/b2b/select?q=*:*&wt=json&indent=true&facet=true&facet.pivot=brandCode,brandName
Interval facet
http://localhost:8080/solr/b2b/select?q=*%3A*&wt=json&indent=true&facet=true&facet.range=price&facet.range.gap=10&facet.range.start=0&facet.range.end=10000
facet.range: Indicates that facet interval query is performed on that domain, facet.range.start indicates the upper limit of the interval, facet.range.end indicates the lower limit of the interval, facet.range.gap: How many parameters are distributed according to each interval value for automatic interval division