SOLR Learning Summary (d) SOLR query parameters

Source: Internet
Author: User
Tags solr solr query

Today is still not related to Java and database operations, mainly to summarize SOLR query parameters, or that sentence, only the first understanding of SOLR's basic content and query syntax, follow-up learning SOLR Java and Database operations, are the things that happen. The parameters required for SOLR queries are listed here first

Wiki address: Http://, which has a detailed description of each parameter.


I. BASIC queries

Q Query keyword, this parameter is the most important, for example, Q=id:1, the default is q=*:*,

FL Specifies which fields are returned, separated by commas or spaces, note that the fields are case sensitive, for example, fl= Id,title,sort

Start returns the first record of the result, general paging, default 0

rows specifies the maximum number of records to return, with a default value of 10, and paging with the start implementation

Sort sorting method, for example, id desc means descending by "id"

WT (writer type) specifies the output format, XML, JSON, PHP, etc.

FQ (filter query) filters queries, providing an optional filter query. Returns the query result for the FQ condition that matches the result in the Q query, for example: Q=id:1&fq=sort:[1 to 5], looking for the keyword ID of 1, and sort is between 1 and 5.

The default query field for DF, which is typically specified by default.

QT (query type) specifies that type to handle query requests, which are generally not specified and are standard by default.

Indent returns whether the result is indented, closed by default, Indent=true|on on, general debugging Json,php,phps,ruby output is necessary to use this parameter.

Version query syntax, we recommend that you do not use it and that the server specifies a default value.

Two. SOLR's search operator

":" Specifies the field to check for the specified value, such as returning all values *:*

“?” A wildcard that represents a single arbitrary character

"*" denotes a wildcard of multiple arbitrary characters (cannot start with the retrieved item * or? symbol)

"~" means a fuzzy search, such as a search for an entry with a spelling similar to "roam": roam~ will find words like foam and roams, roam~0.8, retrieving records that return a similarity of more than 0.8.

And, | | Boolean operator

Or, && Boolean operators

Not 、!、-(the exclusion operator cannot make a query with the item usage alone)

The "+" existence operator requires that the entry after the symbol "+" must exist in the corresponding field of the document 2

() used to form a subquery

[] contains a range of searches, such as retrieving a time period record, including Kinsoku, date:[201507 to 201510]

{} does not contain range retrievals, such as retrieving a time period record, not including the date:{201507 to 201510}

Three. Highlight

H1 is highlighted, hl=true, indicating the use of highlight

HL.FL sets the highlighted field, separated by a space or comma in the field list. 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 the Hl.requiredfieldmatch option.

Hl.requirefieldmatch if set to True, the query results will not be highlighted unless the field is specified with HL.FL. Its default value is False.

Hl.usephrasehighlighter If a query contains a phrase (the quotation marks are framed) then it is guaranteed that the exact phrase must be matched before it is 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, and hl.usephrasehighlighter to true.

The maximum number of characters returned by the hl.fragsize. The default is 100. If 0, then the field will not be fragmented and the value of the entire field will be returned.

Four. Grouping

Official wiki:,

This is the official wiki of facets, with a detailed description of the various parameters of the facet. So here are just a few of the things that are used.

Facet is the core search function of SOLR, mainly navigation (Guided Navigation), parametric query (Paramatic search). The main benefit of facet is that while searching, we can group statistics according to facet condition, give navigation information and improve the search experience.

Facets are mainly divided into two categories: Field facet and Date facet.

1. Field Facet

The facet parameter field must be indexed

Facet=on or Facet=true

Facet.field fields for grouping

Facet.prefix represents the Facet field prefix

Facet.limit facet Field returns the number of bars

Facet.offict the start number, offset, which is used in conjunction with FACET.LIMIT to achieve the effect of paging

Facet.mincount facet field min count, default = 0

Facet.missing if On or true, records whose facet field values are null are counted

Facet.sort indicates the order in which the Facet field values are returned. Format True (count) |false (Index,lex), True (count) indicates that the count value is arranged from large to small, false (Index,lex) is arranged in the natural order of the field values (alphabetical, numeric order). True by default (count)

2. Date Facet

Facet on a field of a date type. SOLR provides a more convenient way to query statistics for date fields. Note that the field type of the date facet must be Datefield (or its subtype). It is important to note that when using a date Facet, the field name, start time, end time, and time interval of the 4 parameters must be provided. This parameter represents a field name that requires a date facet, which, like Facet.field, can be set multiple times to represent a date facet on multiple fields. start time, the general format of time is "2015-12-31t23:59:59z", you can also use "Now", "Year", "MONTH" and so on, End Time time interval, if start is set to 2015-1-1,end for 2016-1-1,gap to "+1month" for 1 months, then the time will be divided into 12 interval segments. represents the gap iteration to end, and the remaining part of the time period, whether to continue to the next interval. The value can be true|false and the default is False.

Example start for 2015-1-1,end is 2015-12-21,gap for "+1month", if Hardend is false, the last time period is 2015-12-1 to 2016-1-1; Conversely, if Hardend is true, the last time period is 2015-12-1 to 2015-12-21.

Note: The fields of facets must be indexed, without participle, without storage. No participle is required because the value of the field represents a holistic concept and does not need to be stored because the user is generally concerned about not the specific value of the field, but rather as a means of grouping the results of the query, to give the relevant grouping information, so as to improve the search experience.

SOLR Learning Summary (d) SOLR query parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.