Home:ALL Converter>Solr dismax Query Over Multiple Fields

Solr dismax Query Over Multiple Fields

Ask Time:2016-01-07T05:35:18         Author:Tom O'Brien

Json Formatter

I am trying to do a solr dismax query over multiple fields, and am a little confused with the syntax.

My core contains a whole load of podcast episodes. The fields in the index are EPISODE_ID, EPISODE_TITLE, EPISODE_DESC, and EPISODE_KEYWORDS.

Now, when I do a query I would like to search for the query term in the EPISODE_TITLE, EPISODE_DESC, and EPISODE_KEYWORDS fields, with different boosts for the different fields.

So when I search for 'jedi', the query I've built looks like this:

http://localhost:8983/solr/episode_core/select?
    &defType=dismax&q=jedi&fl=EPISODE_ID,EPISODE_TITLE,EPISODE_DESC,EPISODE_KEYWORDS
    &qf=EPISODE_TITLE^3.0+EPISODE_DESC^2.0+EPISODE_KEYWORDS

However, this doesn't seem to work - it returns zero records.

When I put a default field like below, it now works, but this is kind of crap because it means I'm not getting results from searching all of the 3 fields:

http://localhost:8983/solr/episode_core/select?&df=EPISODE_DESC
    &defType=dismax&q=jedi&fl=EPISODE_ID,EPISODE_TITLE,EPISODE_DESC,EPISODE_KEYWORDS
    &qf=EPISODE_TITLE^3.0+EPISODE_DESC^2.0+EPISODE_KEYWORDS

Is there something I am missing here? I thought that you could search over multiple fields, and I thought that the 'qf' parameter would mean you didn't need to supply the default field parameter?

All help much appreciated...

Author:Tom O'Brien,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34643231/solr-dismax-query-over-multiple-fields
yy