Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use Facet in Solr

Shulou Source: shulou.com Published: 2022-06-01 18:58:00 10月03日 Update

Solr how to use Facet, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

The basic function of facet is to classify items in search results.

1.facet usage

Facet.field: specify the fields to classify

Facet=on or facet=true indicates that the function is enabled.

Facet.prefix represents the field prefix

Facet.limit indicates the number of records returned

Facet.offict indicates that it starts with several articles and is mainly used for paging.

Facet.query can define queries at will

Note: the index index of the field used for facet must be set to true

2..facet.field

Here we look up the categories of products that contain white in the product name, and know how many records there are in each category.

If you put the query condition Q = white facet.field=CategoryName, you will get the following result

You can see that there are two commodity names in the category T-shirt, including white.

There is one item in the classified pants, including white.

3. Make segmented query by price

The items in the search results can be segmented by price range. Let's take a look at how to segment, open the solrconfig.xml configuration, and find the following nodes

Explicit

ten

Text

Str name= "facet" > on

Price

0

5000

one thousand

The field in the facet.range node that is segmented by range is Price

F.Price.facet.range.start indicates that the starting value is 0

F.Price.facet.range.end indicates a maximum value of 5000

F.Price.facet.range.gap indicates that segments are performed at intervals of 1000 each time.

Finally, the result we see is as follows

0

Tags: Category merchandise query field white result price function name search result node package help search maximum clear lower limit two product Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info MySQL Apple Shulou Technology