Searching in the e-commerce platform is a very important function, mainly including searching word category navigation, automatic prompt and searching sorting.
Automatic prompt: If displayed, You can automatically prompt based on the search term, and display the number of recommended search term documents in the list
Shows the category navigation. For example, if you search for "milk" in the search box, the related category and the attribute corresponding to the current category are displayed.
The following is an example of the above functions.
1. Search and sort
The search function is complex in scoring and sorting of documents. The scoring rules in solr inherit the scoring rules in lucene. Here, we use the dismax query parser of solr to support complex scoring.
When scoring, the following factors are taken into account,
Search keywords match certain fields and score higher than other fields (qf ^)
For some fields, search for the proportion of the phrase score (pf ^)
Calculation of other complex rules, such as sales volume, price, and seller level, can all be considered as factors that affect the score (bf)
Http: // 10.1.1.58: 8080/solr/select? DefType = dismax & qf = name ^ 100 subject ^ 1 & q = sony mp3 & pf = name ^ 100 subject ^ 1 & q. op = OR & bf = sum (recip (MS (NOW, last_modified), 3.16e-11,1, 1), div (1000, price) ^ 100
The meaning of this query is to search for the keywords sony mp3 in name and subject. The proportions of name and subject in the field query are 100 and 1 (qf = name ^ 100 subject ^ 1) respectively ); phrase scores the two fields
PF = Name ^ 100 subject ^ 1, that is, the proportion of name is larger; others also refer to the product price and product update time (BF = sum (recip (MS (now, last_modified), 3.16e-1000, 1), Div (100, price) ^)
2. Automatically prompt facet
Http: // 10.1.1.58: 8080/SOLR/select? Q = *: * & rows = 0 & facet = true & facet. Field = name_autocomplete & facet. prefix = TV
Automatically prompt with facet Based on TV word segmentation, prompting Word Segmentation
3. facet classification navigation
The user searches in the search box, and there is a category navigation below. Category navigation is a tree structure, such
All Categories> milk powder/complementary food/nutrition> Milk Powder
The category can be determined by Attributes. For example, the attributes of milk powder include "brand", "Applicable stage", "applicable age", "packaging method", and "source region ".
In the search box, enter "milk". The search engine will navigate to the "Milk Powder" category and automatically display milk powder-related attributes. There are many implementations and algorithms, the following method can achieve this effect
For classification navigation, you can refer to the first line of the search result. For example, if the first document with the highest score belongs to the 'Milk powder 'category, the navigation will naturally navigate to this category; in addition, the related attributes use the attributes of the milk powder category, such as 'brand', 'applicable staged ', 'applicable age', 'Packaging method', and 'source original ', the ing between categories and attributes can be stored elsewhere.
The tree structure of classification navigation can be implemented using facet. Transform.
Http: // localhost: 8983/SOLR/select? Q = Name: stock & rows = 0 & facet = true & facet. Category = category, category1, category2, category3
The value corresponding to the category attribute, which is implemented using the basic facet.
Http: // 10.1.1.58: 8080/solr/select? Q = name: Milk& Fq = category1: Milk Powder& Fq = category2: milk powder & rows = 0 & facet = true & facet. field = logo& Facet. field =Property1& Amp; facet. field = property2& Amp; facet. field = property3& Amp; facet. mincount = 1