Sudhanshu Jain
Sudhanshu Jain

Reputation: 534

How to use disMax query parser in solr

What is dismax query parser and how to use it. I just want to search for a string in a field in solr by its matching percentage. how to use it getting this done. Please give an example how to use dismax query parser. i have the following document. and i just to get the document which matches fully or partially with the q=Jain Nagar Bla Bla

{
   "id":"2",
   "shipping_firstname":"Sudhanshu",
   "address":"H.No. 444, Gali No.2 Jain Nagar",
   "date_added":"2017-01-21T14:15:15Z",
   "_version_":1562029999829024768}]
}

I am using this query

select?q=Jain Nagar&defType=dismax&m‌​m=2&pf=address&qf=ad‌​dress

Why it doesn't give any result.

Upvotes: 0

Views: 4647

Answers (1)

Vinod
Vinod

Reputation: 1953

Try mm (Minimum Should Match) Parameter of dismax parser.

it has great flexibility to specify Integers or percentage to mm parameter.

Example:

consider 3 docs

doc1: duplicate ipod, doc2:ipod apple, doc3: ipod cable

Lets say query ipod apple. it retrieve docs if it has term either ipod or apple or both. so we get 3 results.

if we use mm=2 with dismax parser

http://localhost:8983/solr/collection_name/select?indent=on&q=ipod apple&wt=json&defType=dismax&mm=2

It fetch docs minimum match of 2 words, specified in query ipod apple. if doc has only one term (say 'ipod') it wont be returned in results.

In result we get only one doc, i.e

doc2

can also specify percentage values to mm parameter(like 75% or -25%)

for more details check Here

Hope this helps, vinod

Upvotes: 1

Related Questions