# Custom Boosting a Page Result

**URL:** <https://discuss.elastic.co/t/custom-boosting-a-page-result/198339>\
**Category:** Elasticsearch\
**Created:** [September 6, 2019, 4:22am UTC](https://discuss.elastic.co/t/custom-boosting-a-page-result/198339 "2019-09-06T04:22:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pocguy](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@pocguy](https://discuss.elastic.co/u/pocguy)\
**Post date:** [September 6, 2019, 4:22am UTC](https://discuss.elastic.co/t/custom-boosting-a-page-result/198339/1 "2019-09-06T04:22:25Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [September 8, 2019, 4:34pm UTC](https://discuss.elastic.co/t/custom-boosting-a-page-result/198339/2 "2019-09-08T16:34:28Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html) has an example of that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 6, 2019, 4:34pm UTC](https://discuss.elastic.co/t/custom-boosting-a-page-result/198339/3 "2019-10-06T16:34:34Z")

</div>

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