1

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...

Tom O'Brien
  • 1,741
  • 9
  • 45
  • 73

1 Answers1

2

Your idea is correct. If you've defined qf (query fields) for Dismax, there shouldn't be any need to specify a df (default field).


Can you be more specific about what isn't working?


Also, read up on Configuration Invariants in solrconfig.xml as it is possible your configuration could be sending some different parameters than you've specified in the URL.

(E.g. if you're seeing a specific error message asking you to provide a df)

Peter Dixon-Moses
  • 3,169
  • 14
  • 18
  • Yes - will edit the question now - was extremely tired when I wrote this. It's a little unclear... Tom – Tom O'Brien Jan 09 '16 at 19:51
  • It returns zero records, even though we know there are lots in the index that match the query. – Tom O'Brien Jan 09 '16 at 19:54
  • Quick debugging: Change `q=*:*` (match all) and make sure you've got data in the index. If you've got data, then it's back to the analysis page (mentioned w your prev solr post) to see the impact of your analyzer setup in scheme.xml. – Peter Dixon-Moses Jan 09 '16 at 20:04
  • You can also pass `debugQuery=true` as a param and see how "jedi" gets rewritten across your three fields. – Peter Dixon-Moses Jan 09 '16 at 20:43
  • If your schema.xml is still the same as from your other post, `debugQuery=true` will help you make sure you're not getting tripped up by case-sensitive field names. (E.g use `episode_desc` etc instead of the all-caps) – Peter Dixon-Moses Jan 09 '16 at 20:49
  • The debugQuery stuff worked for me - it seems I was making a very stupid error - the query field which was being determined programmatically wasn't getting the value I thought for the query without that df field. Total moron! Thanks anyways - I'll ship you the bonus! – Tom O'Brien Jan 10 '16 at 19:00