Solr: How to dynamically elevate limited number of

2020-07-20 04:23发布

问题:

my requirement is to elevate a limited number of (e.g. five) documents for a user request.

What I've got is a single document field which stores a numerical value similar to a boosting value which represents an elevator ranking value.

So a user query would return 5 documents with the highest elevator ranking value and the remaining documents to fill a page in regular order.

How to do that?

The QueryElevationComponent does only allow static query definitions. Boosting does not allow to boost a limited number of documents for the special elevator ranking field.

Do I have to write a modified QueryElevationComponent? If yes, are there good examples how to do that?

Or does another approach exists, I didnt catched up?

Thank you for any hints or ideas!

回答1:

I would have one of these two approaches:

  • Either use an function query to boost on the elevator ranking field.
  • Or use index time boosting to boost the documents that need editorial boosting.

Both these methods can produce unpredictable results (since the relevance model in Solr is very complex). However with the function query you are able to fine tune a bit more.



回答2:

Found a solution using two separate requests.

First boost documents by that score field. Use pagination to limit the result. Take the unique document ids from the result page and boost these ones explicitly within a new request.