DavidVdd
DavidVdd

Reputation: 1018

Solr edismax. How to retrieve the fields that gave the query result

I'm querying mulitple fields using the qf param. But I'm wondering how I can retrieve the field that gave the result.

Example(not a real example):

      q={!edismax qf='tag content'}("tablet")AND("pc")

Field values:

      doc1:
           tag: tablet
           content: The test has failled. Use a pc instead.
      doc2:
           tag: tablet pc
           content: The test has worked.

As a result both documents will be returned because they both have the tablet and pc in their tag/content. Is it possible to know that doc2 had both hits in tag and doc1 only had 1 hit in tag and 1 in content? Debugquery doesn't seem to provide information about this.

I know I can increase the importance of a searchfield using the qf boost.

Upvotes: 0

Views: 152

Answers (2)

Arun
Arun

Reputation: 1787

Ok based on your response to my question.

Unfortunately, there is no way Solr currently returns which fields matched the query as part of your defaulting result docs . If the query is simple, looping over the returned stored fields is probably your best bet. Highlighting is be an option too.

There are couple of other options suggested here : http://grokbase.com/t/lucene/solr-user/117nkf36nq/determine-which-field-term-was-found

Upvotes: 0

Persimmonium
Persimmonium

Reputation: 15791

you can either:

  1. use Highlighting
  2. ask for debug info with debugQuery=true and parse the scoring info to find out.

I think 1 is easier, but it imposes some constraints on your fields (they must be stored for example)

Upvotes: 1

Related Questions