1, common query parameter description
Q-The query string is 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-Specifies the maximum number of records to be returned, together with start to achieve paging.
Sort-order, 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, and later SOLR 1.3 additions, to be notified to us, because the default is not turned on.
FQ-(filter query) query, function: In the Q query conforms to the results of the FQ query is also consistent, for example: q=mm&fq=date_time:[20081001 to 20091031], find the keyword mm, and date_ Time is between 20081001 and 20091031. Official Document: Http://wiki.apache.org/solr/CommonQueryParameters
Not used
Q.op-Override Schema.xml's Defaultoperator (use "and" or "or" when there are spaces), usually by default specifying "or"
DF-The default query field, 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.
Other
Indent-whether the returned result is indented, is closed by default, Indent=true|on is turned on, general debugging Json,php,phps,ruby output is necessary to use this parameter.
Version-the revision of the query syntax is not recommended, and the server specifies the default value.
Configuration examples for Solrconfig.xml
Query configuration (the above parameter items can be configured to the configuration file)
<requesthandler name= "/select" class= "SOLR. Searchhandler ">
<lst name= "Defaults" >
<str name= "Echoparams" >explicit</str>
<int name= "Rows" >10</int>
<str name= "Deftype" >edismax</str>//using the SOLR extended query parser
<str name= "Q.alt" >*:* </str>
<str name= "Fq" >sell_price:[1 to *]</str>
<str name= "HL" >true</str>
<str name= "Hl.fl" >room_name</str>
<str name= "BF" >sum (Product (Termfreq (Room_status, "Dzz"), 1.2), 1) </str>//Additional scoring fields, this is a rating that can affect score
<str name= "PF" >//Fields to query
Room_name house_code room_code zr_house_code hire_commissioner_name broker_name rating_address resblock_name district_ Name Subway_station_name Subway_line_name
</str>
<str name= "QF" >//Weights assigned to each segment
Room_name^5 house_code room_code zr_house_code hire_commissioner_name broker_name rating_address resblock_name^2 District_name Subway_station_name Subway_line_name
</str>
</lst>
</requestHandler>
In addition, the Defaultoperator parameter of Schema.xml is an important parameter, the default is "or", meaning to query the keyword after the word to do "or" connection, and then do the query, and "and", to at least all the keywords to be searched to contain the line.
2. SOLR's search operator
":" Specifies the field to check for the specified value, such as returning all values *:* ²
“?” ² represents a single arbitrary character of a wildcard
"*" denotes a wildcard of multiple arbitrary characters (cannot start with the retrieved item * or symbol) ²
"~" ² indicates 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, retrieves records that return a similarity of more than 0.8.
² Proximity Search, such as retrieving 10 words of "Apache" and "Jakarta", "Jakarta Apache"
"^" ² control correlation Search, such as retrieving Jakarta Apache, and want to make "Jakarta" relevance is better, then add "^" symbol and increment value, that is jakarta^4 Apache
Boolean operator and, | | ²
Boolean operator or, ²&&
Boolean operator not 、!、-² (The exclusion operator cannot be queried separately from the item usage)
The "+" existence operator requires that the entry after the symbol "+" must exist in the corresponding field of the document ²
() used to form a subquery ²
²[] contains range retrieval, such as retrieving a time period record, including Kinsoku, date:[200707 to 200710]
{}² does not contain range retrievals, such as retrieving a time period record, not including the Kinsoku
date:{200707 to 200710}
"Escape operator, special characters include +-²&& | |! () {} [] ^ "~ *?:"
Queries for non-empty data such as: fq=fcode:[' to *] querying fcode non-empty data
Take the inverse instance: fq=!fstate:1
3. Facet Query
Categorical statistical facet
q=*:* &facet=true&facet.field=cat&facet.field=instock//classified by Cat Instock
Q=ipod&facet=true&facet.query=price:[0 to 100]&facet.query=price:[100 to *]//Interval statistic price at 0-100 and 100-infinity
--SOLR Group Query (facet)
Http://IP:port/solr/room/select?rows=0&q=bizcircle_code:XXXXXX&facet=on
&facet.field=resblock_id&facet.field=resblock_name&facet.limit=3//First three resblock under the same bizcircle_code Number of individual documents
When making SOLR queries, SOLR provides a number of parameters to extend its own powerful capabilities. The following are some of the most frequently used parameters.
1. Common
q -the query string, which is required. If you query all *:* , query according to the specified field (Name: Zhang San and Address: Beijing )
FQ -(filter query), the effect: in the Q query conforms to the results of the FQ query is also consistent, for example:q=name: Zhang San &fq=createdate:[20081001 to 20091031], find the keyword mm, and createdate is 20081001
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 -Specifies the maximum number of records to be returned, together with start to achieve paging.
Sort-order, format: Sort=<field Name>+<desc|asc>[,<field name>+<desc|asc>] .... Example: (score desc, price ASC) means "score" descending, then "price" ascending, and the default is correlation descending.
wt -(writer type) specifies the output format, which can have XML, json, php, Phps.
FL Indicates that the index displays those field ( * denotes allfields, if you want to query the specified field separated by commas or spaces (such as:name,sku,shortdescription or Name SKU Shortdescription "Note: Fields are strictly case-sensitive")
Q.op represents the logical operation of the conditions of the query statement in Q and (and) or (or)
HL Whether highlight, such as hl=true
hl.fl Highlight field,Hl.fl=name,sku
hl.snippets : Default is 1, this is set to 3 clips
Hl.simple.pre highlighting the previous format
Hl.simple.post Highlight the following format
facet whether to start statistics
Facet.field Statistics Field
"Note: The above is a more commonly used parameters, of course, the specific parameters to use or more look at SOLR official technical documents and some of the great God's Bovinge, here is just a"
Two, SOLR operator
1. ":" Specifies the field to check for the specified value, such as returning all values *:*
2. "?" indicates the wildcard of a single arbitrary character
3. "*" means more than one wildcard of any character (cannot start with the retrieved item * or symbol)
4. "~" 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, retrieve records that return a similarity of more than 0.8.
5. Proximity search, such as "Apache" and "Jakarta" for retrieving 10 words, "Jakarta Apache"
6. "^" Control correlation search, such as search Jakarta Apache, and want to make "Jakarta" relevance is better, then add "^" symbol and increment value, that is jakarta^4 Apache
7. Boolean operator and, | |
8. Boolean operator or, &&
9. Boolean operator not 、!、-(the exclusion operator cannot be used to compose queries separately from the item usage)
10. "+" existence operator, requires the symbol "+" after the item must exist in the corresponding domain of the document
11. () to form a subquery
12. [] include range search, such as retrieving a time period record, including the tail, date:[200707 to 200710]
13. {} does not include range retrievals, such as retrieving a time period record, without
date:{200707 to 200710}
14./Escape operator, special characters include +-&& | | ! () {} [] ^ "~ *?:/
Note: ①"+" and "-" indicate the adornment of a single query unit, and, or, not is a symbol of whether the two query units do intersect or do the difference or negate the operation
For example:Ab:china +ab:america , said Ab:china ignore dispensable, must meet the second condition is right, not what you think must meet these two search conditions
If input:Ab:china and Ab:america, the parsed result is two conditions at the same time, namely +ab:china and +ab:america or +ab:china +ab:america
In summary, query syntax: modifier field name: Query keyword and/or/not modifier field name: Query keyword
Iii. SOLR query syntax
1. The most common queries, such as the person who queried the surname Zhang ( name: Zhang ), if the exact search is equivalent to a like search in SQL Server that requires a quoted number (""), such as query containing Beijing (Address: "Beijing")
2. Multi-conditional query, note: If you are searching for a single field (name: Search condition plus operator (or, and, not) Name: Search criteria ), such as fuzzy query ( name: Zhang OR Name: Lee single field multi-conditional search is not recommended, the general recommendation is to filter the conditions in a single field, such as ( name: Zhang OR li ), multiple field queries (name: Zhang + Address: Beijing )
3. Sort, such as by name Ascending (nameasc), descending (name desc)
Reference examples for facet use
Cite someone else's blog: http://martin3000.iteye.com/blog/1330106
Http://www.blogjava.net/conans/articles/379556.html