0

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.

AT82
  • 71,416
  • 24
  • 140
  • 167
Sudhanshu Jain
  • 494
  • 3
  • 11

1 Answers1

1

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

Community
  • 1
  • 1
Vinod
  • 1,965
  • 1
  • 9
  • 18
  • i have field address in document having different address values. and i am trying this query. and query is like `solr/orders/select?q=Jain%20Nagar&defType=dismax&indent=on&mm=2&pf=address&qf=address` it return nothing, but i have `H.No. 444, Gali No.2 Jain Nagar` in document's address field. All i want to do is to make a partial search. It means that if some words in query are matching in address field, i want to display them – Sudhanshu Jain Mar 17 '17 at 09:33
  • check schema file for address field and its Type definition. is It set index=true. what analyzers used for that fieldType? – Vinod Mar 17 '17 at 11:09
  • 1
    may be the string type is not analyzed. change type other field type which has proper analyzers. try text_general / any other type which uses class=solr.TextField. remeber if modify schema, you should restart solr and reindex. – Vinod Mar 17 '17 at 13:00
  • i have one more question. if `address: H.No. 444, Gali No.2 Jain Nagar` in document and if `q=Jian Nagar` the it should also consider `Jian` is matched with `Jain`. is it possible..?? – Sudhanshu Jain Mar 18 '17 at 09:07
  • yes. fuzzy string match. ex: `q=jian~0.1` it searches for other token which has Levenshtein distance close to 0.1 with term jian. it will match jain, value should be 0 to 1. – Vinod Mar 20 '17 at 06:50