Article Directory
- Common query
-
- 1. Query all information
- 2. Query by specified single condition
- 3. Query by specifying multiple conditions
- 4. Query matching specified range (for example, the range of product price)
- 4. Sort
- 5. Specify which fields to display (echo)
- 6. Paging query
- 7. Specify the default query field
- 8. Set the highlight
Solr provides a query page, that is, a query page, so that we can simulate a query on this page
Common query
1. Query all information
q Query keywords, this parameter is the most important, for example, q=*: *, query all information
2. Query by specified single condition
For example, query by title q=title:parameter
3. Query by specifying multiple conditions
For example, when querying, not only need to match the title, but also filter by classification. In this case, AND or OR is used.
3.1. Use the fq parameter to achieve multi-condition query
Solr provides fq parameters to help us realize multi-condition queries.
Why use fq parameters? , Because when there are more conditions, writing AND all the time will not be too cumbersome. The fq parameter is an array, and we put our query conditions into an array
4. Query matching specified range (for example, the range of product price)
param: [* TO *]
For example, to query the price of commodity between 10-100 then the expression should be price: [10 TO 100]
For example, to query expression is less than the price of $ 100 for the price [* TO 100]
For example, to query The expression for a price greater than 10 yuan is price[10 TO *]
* represents infinity
4. Sort
4.1. Sort by a single parameter
sort=param_name asc/desc[,param_name asc/desc…]
4.2 Sort by multiple conditions
5. Specify which fields to display (echo)
Solr displays all fields by default without specifying which field to display
fl=param_name[,param_name...]
6. Paging query
Solr is like MySQL's limit grammar. It provides two parameters, start, rows
start: represents which row to display
rows from: represents how many rows are displayed in total
7. Specify the default query field
If no query parameters are specified, query according to the default fields
8. Set the highlight
When we search on Baidu, Baidu will highlight the records we generally query
solr also supports highlighting