DisMax query parser parameters

Apart from common parameters, the following is a list of all parameters supported by the DisMax Query Parser. All the default values for these parameters are configured in solrconfig.xml:

Parameter

Behavior

q

Specifies a query string with no special characters and treats Boolean operators + and - as term modifiers. Wildcard characters like * are not supported by this parameter:

  • q=apache
  • q="Apache Lucene"

a.alt

Defines an alternate query when the main query parameter q is not specified or blank. This parameter is mainly used to match all documents to get faceting counts.

qf

The qf parameter assigns a boost factor to a specific field to increase or decrease its importance in the query. For example, qf="firstField^3.4 secondField thirdField^0.2" assigns firstField a boost of 3.4, keeps secondField with the default boost, and assigns thirdField a boost of 0.2. These boost factors make matches in firstField much more significant than matches in secondField, which becomes much more significant than matches in thirdField.

mm

The minimum parameter defines the minimum number of optional clauses that must match. Words or phrases specified in the q parameter are considered as optional clauses unless they are preceded by a Boolean AND or OR

Possible values for the mm parameter are integer (positive and negative), percentage (positive and negative), simple, or multiple conditional expressions.

The default value for mm is 100%, which means all clauses must match. 

pf
The Phrase Fields (pf) parameter boosts the score of a document when all the terms in the q parameter appear in close proximity.
ps
The Phrase Slop (ps) parameter specifies the number of positions a term is required to move to match a phrase specified in a query with the pf parameter.
qs
Similar to the ps parameter for the pf parameter, the Query Phrase Slop (qs) defines the amount of slop on phrase queries explicitly included in the user's query string with the qf parameter.
tie

The tie breaker parameter specifies a float value (which should be something much less than 1) to use as a tiebreaker when a query term is matched in more than one field in a document.

bq

The Boost Query (bq) parameter specifies an additional and optional query clause that will be added to the user's main query to influence the score. For example, if you want to add a relevancy boost for recent documents:

q=apache
bq=date:[NOW/DAY-1YEAR TO NOW/DAY]

Multiple bq parameters can also be used when a query needs to be parsed as separate clauses with separate boosts.

bf

The Boost Functions (bf) parameter specifies functions (with optional boosts) that will be added to the user's main query to influence the score. Any function supported natively by Solr can be used along with a boost value. For example, if you want to show the most recent documents first, this is the syntax:

bf=recip(rord(createddate),1,100,100)

 

We have seen all the configuration parameters for DisMax Query Parser and now we are ready to run a search using DisMax query parser.

The query ID is SP2514N and all DisMax Parser parameters are default, which means we are not specifying values in those parameters.

The URL is http://localhost:8983/solr/techproducts/select?defType=dismax&q=SP2514N&wt=json

The following shows the Solr admin console showing an example for DisMax query parser:

Response

{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"SP2514N",
"defType":"dismax",
"wt":"json",
"_":"1515607090788"}},
"response":{"numFound":1,"start":0,"docs":[
{
"id":"SP2514N",
"name":"Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133",
"manu":"Samsung Electronics Co. Ltd.",
"manu_id_s":"samsung",
"cat":["electronics",
"hard drive"],
"features":["7200RPM, 8MB cache, IDE Ultra ATA-133",
"NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor"],
"price":92.0,
"price_c":"92.0,USD",
"popularity":6,
"inStock":true,
"manufacturedate_dt":"2006-02-13T15:26:37Z",
"store":"35.0752,-97.032",
"_version_":1583131913641525248,
"price_c____l_ns":9200}]
}}

Example: Retrieve only field id and name with score

URL: http://localhost:8983/solr/techproducts/select?defType=dismax&q=SP2514N&fl=id,name,score

Response:

{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"SP2514N",
"defType":"dismax",
"fl":"id,name,score"}},
"response":{"numFound":1,"start":0,"maxScore":2.6953351,"docs":[
{
"id":"SP2514N",
"name":"Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133",
"score":2.6953351}]
}}

Use fl=* to retrieve all the fields.

Example: Now we search for query iPod, assigning boosting to the fields features and cat.

URL: http://localhost:8983/solr/techproducts/select?defType=dismax&q=iPod&qf=features^10.0+cat^0.5

Response:

{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"iPod",
"defType":"dismax",
"qf":"features^10.0 cat^0.5"}},
"response":{"numFound":1,"start":0,"docs":[
{
"id":"IW-02",
"name":"iPod & iPod Mini USB 2.0 Cable",
"manu":"Belkin",
"manu_id_s":"belkin",
"cat":["electronics",
"connector"],
"features":["car power adapter for iPod, white"],
"weight":2.0,
"price":11.5,
"price_c":"11.50,USD",
"popularity":1,
"inStock":false,
"store":"37.7752,-122.4232",
"manufacturedate_dt":"2006-02-14T23:55:59Z",
"_version_":1583131913695002624,
"price_c____l_ns":1150}]
}}

Example: Boost results that have a field that matches a specific value.

URL: http://localhost:8983/solr/techproducts/select?defType=dismax&q=iPod&bq=cat:electronics^5.0

In the same way, we can construct a URL for other parameters as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.181