Custom Boosting a Page Result

I am trying to promote a given page to the top of search result. Currently say, the page appears on the 3rd item in the search results. I wish to have this to the top of the search result.

The current way of implementing is to give this page a constant value and index into a field(custom_boost) in elastic search. During query time I use the function_score query to multiply the score with the custom_boost to increase the overall score.

This all works. I search for the term and can see the page promoted to the top of search result. However I wish to only see the page boosted for the given query. Currently, if the page appears in any search result the custom_boost value is picked up and the overall score is increased causing incorrect ordering.

Can we do boosting of a page based on a query term, instead of specifying the boost at the page level?

You can combine the function you're using to boost the page with a filter. That way, only documents matching that match that filter will get boosted. The second code snippet on the documentation page for the function_score query has an example of that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.