solrdismax

DisMax query parser is not running


Environment- solr-8.9.0

Movies data in a form of a .csv file has been indexed in apache solr.

Movies data

name,directed_by,genre,type,id,initial_release_date
.45,Gary Lennon,Black comedy|Thriller|Psychological thriller|Indie film|Action Film|Crime Thriller|Crime Fiction|Drama,,/en/45_2006,2006-11-30
9,Shane Acker,Computer Animation|Animation|Apocalyptic and post-apocalyptic fiction|Science Fiction|Short Film|Thriller|Fantasy,,/en/9_2005,2005-04-21
Bomb the System,Adam Bhala Lough,Crime Fiction|Indie film|Coming of age|Drama,,/en/bomb_the_system,
movie_name,Adam Bhala,Animation|Indie film|Coming of age|Drama,,/en/bomb_the_system,

The DisMax Query Parser has been run over the field 'directed_by'. 'directed_by' field is mapped as a 'text_general' field-type in managed-schema.

I have run the following query over solr

curl -G http://localhost:8983/solr/testCore1/select --data-urlencode "q=directed_by:'Adam Bhala Lough~'" --data-urlencode "defType=dismax" --data-urlencode "mm=2"

but the above query is giving 0 'numFound' in response. I expect the following field to match:

Adam Bhala
Adam Bhala Lough

I expect the following field not to match:

Adam Gary Lennon

Although data is indexed in solr. I have cross-checked this by running the following query without disMax query parser and it is giving responses.

curl -G http://localhost:8983/solr/testCore1/select --data-urlencode "q=directed_by:'Adam Bhala Lough~'"

Why dismax query parser is not running as it should be? I understand that mm(Minimum Should Match) Parameter===> defines the minimum number of clauses that must match.

I have spent hours to solve this. However, I cannot seem to find anything that holds my hand. Could someone help me find the missing piece?

Reference https://solr.apache.org/guide/8_9/the-dismax-query-parser.html

How to use disMax query parser in solr


Solution

  • You need to use the qf (query fields) parameter to specify in which field(s) the search should be performed, along with (optionally) a boost factor used to increase or decrease that particular field’s importance in the query (defaults to 1) :

    q=Adam Bhala Lough~
    qf=directed_by
    

    Or, use edismax query parser instead of dismax, so that the standard query syntax you were using (directed_by:'Adam Bhala Lough~') can work as intended.