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