1

All:

What I want to do is to highly score documents which have "season" in content field AND heavily punish documents with "season" in the title field AND boost the newly created documents.

I wonder how to do that in Dismax(or eDismax)? Thanks

Kuan
  • 11,149
  • 23
  • 93
  • 201

3 Answers3

1

Boosting on qf parameter will boost the field regardless of value in the field. In order to boost documents that contains the keyword "season" in the content field use "bq" parameter instead. For ex.

select?q=*&bq=content:season^50&bq=title:season^0.001

To boost newly created documents use a boost function like

recip(ms(NOW,mydatefield),3.16e-11,1,1)

where mydatefield is the field containing the timestamp of when the document is created or updated.

More details on the usage of boost functions can be found here

  • Thanks, I am a little confused about the q and bq, [1] does that means I only need to specify what I want to search and boost in bq and without caring what inside q? [2] how to punish the document by give a negative boost? – Kuan Apr 02 '15 at 17:09
  • [1] yes q parameter is used for general keyword search and bq is used as a boosting query that is applied for all searches. [2] Giving a lower boost value to the conditions that you want a negative boost would reduce the score of the documents matching this condition. In the example above the boost of .001 would lower the score for documents that contain season in title. – Prabhu Velayutham Apr 02 '15 at 18:04
  • Thanks, I will try it see if I can figure out. – Kuan Apr 02 '15 at 18:10
0

While using dismax (or edismax) query parser, query fields are specified under qf parameter, and the boosting is applied there too. For example, in your case:

select?q=season&qf=content^1000 title^0.001&defType=dismax

For boosting the newly created documents, you also need to specify what happens when an older document has a higher score based on the search criteria. If you mean that in case of equal score, the new document should be above then add

sort=score desc,created_at desc

to your query, assuming that you are storing the insertion time under a field name "created_at".

Saurabh Tewari
  • 331
  • 1
  • 4
  • 6
0

In DisMax, you can reduce the relevance score of documents that have the word 'season' in the field title by using:

    - ['bf', "if(tf(title,'season'),-5,0)"]

Example. If a document's relevance score is 5.6 without the bf relevance boost, and the document has word content in title field, the document's relevance score will be 5.1 after applying bf because Solr multiplies -5 by queryNorm (which is constant for all documents in a result set, and does not affect its order) before adding the product to the relevance score. For this example, let's assume queryNorm = 0.1 so 5.6 - (5 * 0.1) gives 5.1.

The code above is in yaml format, which is used for relevance settings in VuFind.

teemutalja
  • 31
  • 4