The following list of parameters are supported by both the DisMaxRequestHandler and the StandardRequestHandler. Although they are not mandatory, it is strongly encouraged that all Future SolrRequestHandlers support them as well. Some Utilities exist to make implementing them easy.

sort

Handlers that support sorting including DisMaxRequestHandler and the StandardRequestHandler use a common parameter "sort"

Examples

sort

Meaning

by default, it is the same as score desc

score desc

sort from highest score to lowest score

price asc

sort in ascending order of the "price" field

inStock desc, price asc

sort by "inStock" descending, then "price" ascending

Sorting can be done on the "score" of the document, or on any multiValued="false" indexed="true" field provided that field is either non-tokenized (ie: has no Analyzer) or uses an Analyzer that only produces a single Term (ie: uses the KeywordTokenizer)

The common situation for sorting on a field that you do want to be tokenized for searching is to use a <copyField> to clone your field. Sort on one, search on the other.

NOTE:

  1. A sort ordering must include a field name (or score as a fake field), followed by whitespace (escaped as + or %20 in URL strings), followed by a sort direction (asc or desc).

  2. Multiple sort orderings can be separated by a comma, ie: sort=<field name>+<direction>[,<field name>+<direction>]...

start

This parameter is used to paginate results from a query. When specified, it indicates the offset in the complete result set for the queries where the set of returned documents should begin. (i.e. the first record appear in the result set is the offset)

The default value is "0".

rows

This parameter is used to paginate results from a query. When specified, it indicates the maximum number of documents from the complete result set to return to the client for every request. (You can consider it as the maximum number of result appear in the page)

The default value is "10"

fq

"fq" stands for Filter Query.

This parameter can be used to specify a query that can be used to restrict the super set of documents that can be returned, without influencing score. It can be very useful for speeding up complex queries since the queries specified with fq are cached independently from the main query. Caching means the same filter is used again for a later query (i.e. there's a cache hit). See SolrCaching to learn about the caches Solr uses. See FilterQueryGuidance for an explanation of how filter queries may be used for increased efficiency.

NOTE:

  1. The fq param can be specified multiple times. Documents will only be included in the result if they are in the intersection of the document sets resulting from each fq. In the example below, only documents which have a popularity greater then 10 and have a section of 0 will match.

      fq=popularity:[10 TO *]
    & fq=section:0
  2. Filter Queries can be complicated boolean queries, so the above example could also be written as a single fq with two mandatory clauses...

      fq=+popularity:[10 TO *] +section:0   
  3. The document sets from each filter query are cached independently. Thus, concerning the previous examples: use a single fq containing two mandatory clauses if those clauses appear together often, and use two separate fq params if they are relatively independent.
  4. As with all parameters: when expressed in a URL, special characters need to be properly URL escaped.

fl

This parameter can be used to specify a set of fields to return, limiting the amount of information in the response. When returning the results to the client, only fields in this list will be included.

The set of fields to be returned can be specified as a space (or comma) separated list of field names. The string "score" can be used to indicate that the score of each document for the particular query should be returned as a field, and the string "*" can be used to indicate all stored fields the document has.

Examples

Field List

Meaning

id name price

Only return the "id", "name", and "price" fields

id,name,price

Same as above

id name, price

Same as above

id score

Return the "id" field and the score

*

Return all fields the each document has

* score

Return all fields each document has, along with the score

The default value is "*"

debugQuery

If this parameter is present (regardless of its value) then additional debugging information will be included in the response, including "explain" info for each of the documents returned. This debugging info is meant for human consumption... its XML format could change in the future.

The default behavior is not to include debugging info.

explainOther

This parameter allows clients to specify a Lucene query to identify a set of documents. If non-blank, the explain info of each document which matches this query, relative the main query (specified by the q parameter) will be returned along with the rest of the debugging information.

The default value is blank (i.e. no extra explain info will be returned)

defType

The defType parameter can be used to specify the query parser to use with this request. See http://lucene.apache.org/solr/api/org/apache/solr/search/QParserPlugin.html and http://wiki.apache.org/solr/SolrPlugins#head-60a8c7a0663bd05a528899e7719ffe52522a21c2

timeAllowed

<!> Solr1.3

The time allowed for a search to finish. This value only applies to the search and not to requests in general. Time is in milliseconds. Values <= 0 mean no time restriction. Partial results may be returned (if there are any).

omitHeader

Range: {true|false}

Exclude the header from the returned results. The header contains information about the request, such as the time it took to complete. The default is false.

CommonQueryParameters (last edited 2009-09-20 22:04:43 by localhost)