Query parameters
Common:
q
-query string, required.
fl
-Specifies that the contents of those fields be returned, separated by commas or spaces.
start
-Returns the offset position of the first record in the full found result, starting at 0, for general paging.
rows
-Specify the maximum number of records to be returned, with start to achieve paging.
sort
-Sort, format: sort=<field name>+<desc|asc>[,<field name>+<desc|asc>]
. Example: (Instock desc, price asc) means "instock" descending, then "price" ascending, and the default is correlation descending.
wt
-(writer type) specifies the output format, which can have XML, JSON, PHP, Phps.
fq
-(filter query) FQ query, function: In the Q query matches the result is also the same as the query, for example: q=mm&fq=date_time:[20081001 TO 20091031]
, find the keyword mm, and date_time is between 20081001 to 20091031
Not used:
defType
:
q.op
-Schema.xml Defaultoperator (with "and" or "or" in the case of a space), typically specified by default
df
-Default query fields, typically specified by default
qt
-(query type) specifies that type to handle query requests, which are generally not specified and are standard by default.
Other:
indent
-If the returned result is indented, it is closed by default, and indent=true|on
it is necessary to use this parameter for general debug Json,php,phps,ruby output.
version
-the version of the query syntax, it is recommended not to use it, by the server to specify the default value.
Retrieving operators
:
Specifies that the field checks for the specified value, such as returning all values :
?
A wildcard that represents a single arbitrary character
*
A wildcard that represents multiple arbitrary characters (cannot start with the retrieved item * or? symbol)
~
Represents a fuzzy search, such as retrieving an entry with a spelling similar to "roam": roam~ will find words like foam and roams, and roam~0.8, retrieving records that return a similarity of more than 0.8. Proximity search, such as retrieving 10 words of "Apache" and "Jakarta", "Jakarta Apache"
^
Control relevance search, such as retrieving Jakarta Apache, and hoping to make "Jakarta" more relevant, then add "" Symbol and increment value, that is, JAKARTA4 Apache
- Boolean operator
AND、||
- Boolean operator
OR、&&
- Boolean operator
NOT、!、-
(the exclusion operator cannot be a singleton query with the item usage)
+
An operator exists that requires that the item after the symbol "+" must exist in the corresponding field of the document
()
Used to form subqueries
[]
Include range retrieval, such as retrieving a time period record, including the tail, date:[200707 to 200710]
{}
Does not include range retrieval, such as retrieving a time period record, not including Kinsoku, date:{200707 to 200710}
"
Escape operators, special characters include +-&& | | ! ( ) { } [ ] ^ " ~ * ? : "
Example
http://localhost:8080/solr/primary/select?q=*:*
- 2. Limit the return field
http://localhost:8080/solr/primary/select?q=*:*&fl=productId
means: Query all records, return only the ProductID field
http://localhost:8080/solr/primary/select?q=*:*&fl=productId&rows=6&start=0
Means: Query the first six records, return only the ProductID field
- 4. Additional Qualifications
http://localhost:8080/solr/primary/select?q=*:*&fl=productId&rows=6&start=0&fq=category:2002&fq=namespace:d&fl=productId+category&fq=en_US_city_i:1101
means: Query category=2002, en_US_city_i=110
and the first six records of Namespace=d, return only ProductID and category fields
http://localhost:8080/solr/primary/select?q=*:*&fl=productId&rows=6&start=0&fq=category:2002&fq=namespace:d&sort=category_2002_sort_i+asc
Represents: Query category=2002 and Namespace=d and category_2002_sort_i
the first six records sorted in ascending order, returning only the ProductID field
Realistic Grouping Statistics results
http://localhost:8080/solr/primary/select?q=*:*&fl=productId&fq=category:2002&facet=true&facet.field=en_US_county_i&facet.field=en_US_hotelType_s&facet.field=price_p&facet.field=heatRange_ihttp://localhost:8080/solr/primary/select?q=*:*&fl=productId&fq=category:2002&facet=true&facet.field=en_US_county_i&facet.field=en_US_hotelType_s&facet.field=price_p&facet.field=heatRange_i&facet.query=price_p:[300.00000+TO+*]
Highlight
hl-highlight
, h1=true
which indicates the highlight is used. You can use it h1.fl=field1,field2
to set the highlighted field.
hl.fl
: A list of fields separated by a space or comma. To enable the highlight function of a field, you have to ensure that the field is stored in the schema. If the parameter is not given, then the default field, standard handler, is used with the DF parameter, and the Dismax field is used with the QF parameter. You can use asterisks to highlight all the fields conveniently. If you are using wildcard characters, consider enabling.
hl.requireFieldMatch
: If set to true, the field will be highlighted unless the query result is not empty. Its default value is False, which means it may match a field but highlight a different field. If a wildcard character is used by HL.FL, then this parameter must be enabled. However, if your query is the all field (possibly using the Copy-field Directive), set it to false so that the search results indicate which field the query text is not found
- H
l.usePhraseHighlighter
: If a query contains a phrase (the quotation marks are framed) then it is guaranteed that the exact phrase must be matched to be highlighted.
hl.highlightMultiTerm
If you use wildcards and fuzzy searches, you will ensure that the term that matches the wildcard character is highlighted. The default is False, which hl.usePhraseHighlighter
is also true.
hl.snippets
: This is the maximum number of highlighted fragments. The default value is 1 and is almost never modified. If the value of a particular field is set to 0 (for example f.allText.hl.snippets=0
), this indicates that the field is disabled highlighting. You might use it when you're hl.fl=*.
hl.fragsize
: The maximum number of characters returned per snippet. The default is 100. If 0, then the field will not be fragmented and the value of the entire field will be returned. This is not done in large print.
hl.mergeContiguous
: If set to True, the snippet will merge when overlapping.
hl.maxAnalyzedChars
: Will search for the highlighted maximum character, the default value is 51200, if you want to disable, set to 1
hl.alternateField
: If no snippet is generated (no terms match), another field value is used as the return.
hl.maxAlternateFieldLength
: If hl.alternateField
enabled, it is sometimes necessary to set the maximum character length for Alternatefield, with the default of 0 being no limit. So a reasonable value is that the hl.snippets * hl.fragsize
size of the returned result should be consistent.
hl.formatter
: An extension point that provides a replaceable formatting algorithm. The default value is simple, which is the only option available at this time. Obviously this is not enough, you can see org.apache.solr.highlight.HtmlFormatter.java
how the highlighting element is configured in Solrconfig.xml. Note that no matter what value is highlighted in the original text, such as the pre-existing EM tags, will not be escaped, so in some cases will cause false highlighting. - hl.fragmenter
: This is the extension point for SOLR to develop the fragment algorithm. Gap is the default value. The Regex is another option that indicates that the bounds of the highlight are determined by a regular expression. This is an atypical advanced option. To know how the default settings and Fragmenters (and formatters) are configured, you can look at the highlight segment in Solrconfig.xml.
hl.regex.pattern
: Pattern of regular expressions
hl.regex.slop
: This is a factor that hl.fragsize can change to fit the regular expression. The default value is 0.6, meaning if hlfragsize=100
the size of the fragment will be from 40-160.
----EOF-----
Apache SOLR query Syntax (GO)