Is it possible to boost mlt queries in solr?

2019-05-13 16:28发布

问题:

Specifically if I'm doing a query using the solr mlt handler (http://wiki.apache.org/solr/MoreLikeThisHandler) and stream.body to supply the source doc is there any way to boost result documents based on document age?

I already know how to do that for a regular query using dismax (http://wiki.apache.org/solr/FunctionQuery#Date_Boosting) but I can't quite figure out the magic incantation to do it for the mlt handler.

回答1:

It looks like the mlt handler is written to handle one of two cases:

  1. q=[typical query goodness which can include date boosting]
  2. stream.body=[url]

If q is present, stream.body is ignored and vice-versa, so unfortunately I don't think you'll be able to do what you want in a single call without patching the MoreLikeThisHandler.


BUT: If you need this in a hurry, you can do it with two queries

  1. Run your same MLT query solely for the purpose of retrieving the interesting-terms and boosts (e.g with mlt.interestingTerms=details&mlt.boost=true&rows=0)
  2. Using the interesting-terms and boosts from (1), run a standard Solr query (non-MLT) with the date-boosting function you desire.


标签: solr