In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the syntax of SOLR query". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the syntax of SOLR query".
one。 Basic query
Q-query string, required.
Fl-specifies which field contents are returned, separated by commas or spaces.
Start-returns the offset of the first record in the complete finding result, starting at 0, usually used for paging.
Rows-specifies the maximum number of records returned as a result, and works with start to achieve paging.
Sort-sort, format: sort=+ [, +]... . Example: (inStock desc, price asc) means "inStock" descending order, and then "price" ascending order. The default is correlation descending order.
Wt-(writer type) specifies the output format, which can be xml, json, php, phps. If solr 1.3 is added later, you need to notify us because it is not opened by default.
Fq-(filter query) worry query, function: in Q query match result is also fq query match, for example: q=mm&fq=date_time: [20081001 TO 20091031], find the keyword mm, and date_time is between 20081001 and 20091031.
Q.op-overrides the defaultOperator of schema.xml (use "AND" or "OR" operation logic when there are spaces), which is generally specified by default
Df-default query field, which is generally specified by default
Qt-(query type) specifies which type to handle query requests, usually not specified, and defaults to standard.
-exclude adding "-" (excluding "sign") before the word to be excluded
Other
Indent-whether the returned result is indented. It is turned off by default and enabled with indent=true | on. This parameter is only necessary for debugging json,php,phps,ruby output.
Version-the version of the query syntax, which is not recommended, and the default value specified by the server.
[retrieval operator for Solr]
":" the specified field looks up the specified value, such as returning all values *: * ²
"?" ²represents the wildcard of a single arbitrary character.
"*" indicates a wildcard of multiple arbitrary characters (cannot be used at the beginning of the retrieved item * or? Symbol) ²
"~" ²means fuzzy retrieval, such as retrieving items with spelling similar to "roam", such as: roam~ will find words like foam and roams; roam~0.8, retrieval returns records with a similarity of more than 0.8.
²proximity search, such as "apache" and "jakarta", "jakarta apache" ~ 10 words separated by 10 words
"^" ²controls relevance retrieval, such as retrieving jakarta apache, and wants to make "jakarta" more relevant, then add a "^" symbol and an increment value after it, that is, Jakarta ^ 4 apache
Boolean operators AND, | | ²
Boolean operators OR, ²& &
Boolean operators NOT,!,-²(exclusion operators cannot be used alone with items to form a query)
The "+" operator exists, which requires that the item after the symbol "+" must exist in the corresponding field of the document.
() used to construct a subquery ²
²[] contains a range search, such as retrieving a record for a time period, including head and tail, date: [200707 TO 200710]
{} ²does not include range retrieval, such as retrieving records for a certain period of time, excluding head and tail
Date: {200707 TO 200710}
"escape operator, special characters including +-& |! () {} [] ^" ~ *?: "
two。 Highlight
Hl-highlight,h2=true, indicating the use of highlights. You can set the highlighted fields with h2.flashfield1 field 2.
Hl.fl: a list of fields separated by spaces or commas. To enable the highlight function of a field, you have to make sure that the field is stored in schema. If this parameter is not given, the default field standard handler uses the df parameter and the dismax field uses the qf parameter. You can use an asterisk to easily highlight all fields. If you use wildcards, consider enabling the hl.requiredFieldMatch option.
Hl.requireFieldMatch:
If set to true, it will be highlighted unless the query result of the field is not empty. Its default value is false, which means that it may match a field but highlight a different field. If hl.fl uses wildcards, enable this parameter. However, if your query is an all field (possibly using the copy-field instruction), set it to false so that the search results can indicate which field's query text has not been found
Hl.usePhraseHighlighter:
If a query contains a phrase (enclosed in quotation marks), it is guaranteed that the phrase must be exactly matched before it is highlighted.
Hl.highlightMultiTerm
If you use wildcards and fuzzy search, make sure that the term that matches the wildcard is highlighted. The default is false, and hl.usePhraseHighlighter is true.
Hl.snippets:
This is the maximum number of highlighted fragments. The default value is 1 and will hardly be modified. If the value of a particular field is set to 0 (such as f.allText.hl.snippets=0), this indicates that the field is highlighted. You might use it on hl.fl=*.
Hl.fragsize:
The maximum number of characters returned per snippet. The default is 100. If 0, the field will not be fragmented and the value of the entire field will be returned. You don't do this when you have large fields.
Hl.mergeContiguous:
If set to true, it will merge when the snippet overlaps.
Hl.maxAnalyzedChars:
Will search for the maximum highlighted character. The default value is 51200. If you want to disable it, set it 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 is enabled, it is sometimes necessary to set the maximum character length of alternateField, which is unlimited by default of 0. So the reasonable value should be
Hl.snippets * hl.fragsize so that the size of the returned result can be maintained.
Hl.formatter: an extension point that provides an alternative formatting algorithm. The default value is simple, which is currently the only option available.
Obviously this is not enough, you can see how the highlighting element is configured in org.apache.solr.highlight.HtmlFormatter.java and solrconfig.xml.
Note that no matter what value is highlighted in the original text, such as the pre-existing em tags, it will not be escaped, so it will sometimes lead to false highlighting.
Hl.fragmenter:
This is the extension point of Solr's fragment algorithm. Gap is the default value. Regex is another option, which indicates that the boundary of the highlight is determined by a regular expression. This is an atypical advanced option. To see how the default settings and fragmenters (and formatters) are configured, take a look at the highlight section in solrconfig.xml.
The fragmenter of regex has the following options:
Hl.regex.pattern: pattern of regular expressions
Hl.regex.slop: this is the factor by which hl.fragsize can change to accommodate regular expressions. The default value is 0. 6, which means that if hl.fragsize=100, the size of the fragment will range from 40 to 160.
Thank you for your reading, the above is the content of "what is the syntax of SOLR query?" after the study of this article, I believe you have a deeper understanding of what the syntax of SOLR query has, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.