solr basic query

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

Insert picture description here

2. Query by specified single condition

For example, query by title q=title:parameter

Insert picture description here

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.

Insert picture description here

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

Insert picture description here

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

Insert picture description here

4. Sort

4.1. Sort by a single parameter

sort=param_name asc/desc[,param_name asc/desc…]

Insert picture description here

4.2 Sort by multiple conditions

Insert picture description here

5. Specify which fields to display (echo)

Solr displays all fields by default without specifying which field to display
fl=param_name[,param_name...]
Insert picture description here

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

Insert picture description here

7. Specify the default query field

If no query parameters are specified, query according to the default fields

Insert picture description here

8. Set the highlight

When we search on Baidu, Baidu will highlight the records we generally query

Insert picture description here

solr also supports highlighting

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42418169/article/details/112471891