1

I'm using Solr 5.4.1 and all documents have the following XML structure:

<?xml version ="1.0" ?>
    <add >
        <doc >
            <field name ="title">US, Qatar Extend Talks OverFormer Taliban Detainees - Wall Street Journal</field>
            <field name ="date">2015-05-31T23:39:45Z</field>
            <field name ="description">The U.S. and Qatari governments have extended talks over the fate of five former Afghan Taliban prisoners ho were released from the Guantanamo Bay prison a year ago in exchange for an American soldier , U.S. officials said Sunday.</field>
        </doc >
</add >

As you can see from the structure, there are the fields title and description.

I would like to do some tests:

1) To search text in both fields as if they were one UNIQUE field.

2) To search text in both fields giving a different relevance weight to each field (e.g. 80% to description and 20% to title).

I know that we can use the parameter qf to specify where to search (fields); but I know that there is also the boolean operator AND to be specified in a parameter q.

Which one of the above mentioned tecniques can I use to do each tests?

glorfindel
  • 199
  • 3
  • 11

1 Answers1

0
  1. If you want to search both fields as a single field, add a new field (i.e. title_description) and use two copyField instructions to copy the content from both fields into the common field:

  2. You can use qf with description^4 title to give any hits in description four times the weight of any hits in title. This will give you a 80/20 ratio, but remember that scoring is more complex than just simple percent weights between fields - the length of the content, the number of times the term is present, the position between fields (if using phrase boosting), etc.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • Thanks for the answer!!! And what's the difference between using `q=title:some_text OR description:some_text` and `q=some_text & qf=description title`? – glorfindel Jun 01 '16 at 21:24
  • @MatteoBernardon You can use `debugQuery=true` to see for yourself if anything changes in the score calculations - my guess is that the latter is expanded to the former, so they should be close to (if not) identical. – MatsLindh Jun 02 '16 at 09:00