# Assign boost to document at index time

**URL:** https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690
**Category:** Elasticsearch
**Created:** [March 6, 2018, 10:10am UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690 "2018-03-06T10:10:11Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Kurzer\_Patrick](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@Kurzer\_Patrick](https://discuss.elastic.co/u/Kurzer_Patrick)
#### Post date: [March 6, 2018, 10:10am UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/1 "2018-03-06T10:10:11Z")

</div>

I just read much documents regarding to assign a static boost to a specific document at index time. Some of the docs and function are deprecated. So I am not sure what to use for this particular use case:

I index two simple documents:

`Germany` and `Gerogia` in the same index. `Germany` should have a higher ranking by default because its a country.

Whats the best ways to get this working?

And is [this article](https://marcobonzanini.com/2015/06/22/tuning-relevance-in-elasticsearch-with-custom-boosting/) a good source to get it working?

I'm using version 5.5.0

Thanks in advance

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 6, 2018, 3:22pm UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/2 "2018-03-06T15:22:59Z")

</div>

I think your question duplicates the one you opened previously at [Pre boost while indexing](https://discuss.elastic.co/t/pre-boost-while-indexing/122660)

---

<div class="post-metadata">

### Author: ![Kurzer\_Patrick](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@Kurzer\_Patrick](https://discuss.elastic.co/u/Kurzer_Patrick)
#### Post date: [March 6, 2018, 3:37pm UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/3 "2018-03-06T15:37:00Z")

</div>

Yes. I was not able to delete the previous one. The description of the use case of the post is simpler than in the other question.

---

<div class="post-metadata">

### Author: ![Kurzer\_Patrick](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@Kurzer\_Patrick](https://discuss.elastic.co/u/Kurzer_Patrick)
#### Post date: [March 6, 2018, 3:44pm UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/4 "2018-03-06T15:44:13Z")

</div>

Some additional information regarding my researches today.

One option is to use `field_value_factor`. Which means I create a new field in my document similar to weight to calculate the score by query time. [Docs](https://www.elastic.co/guide/en/elasticsearch/guide/current/boosting-by-popularity.html)

An additional or other option is the boost on a specific field. In simple words I create another field in my document for example `country:boolean` and by query time I boost the field country by any value if its true. [Docs](https://www.elastic.co/guide/en/elasticsearch/guide/current/query-time-boosting.html)

What do you think? Is that the right way to go?

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [March 6, 2018, 4:27pm UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/5 "2018-03-06T16:27:11Z")

</div>

I wrote about using function scores over index-time boosts over four years  
ago: [http://blog.brusic.com/2014/02/document-boosting-in-elasticsearch.html](http://blog.brusic.com/2014/02/document-boosting-in-elasticsearch.html)

Since then the function score query has improved, with options such  
as field\_value\_factor. The main takeaway is the same, function scores after  
the scoring, to me at least, are more consistent and easier to read.

---

<div class="post-metadata">

### Author: ![Kurzer\_Patrick](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@Kurzer\_Patrick](https://discuss.elastic.co/u/Kurzer_Patrick)
#### Post date: [March 6, 2018, 4:57pm UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/6 "2018-03-06T16:57:21Z")

</div>

Thanks Ivan, nice post. Makes some stuff more clear. I will need the stuff for autocomplete functions. If you have any other related documents to share, would be good the have those.

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [March 6, 2018, 9:50pm UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/7 "2018-03-06T21:50:28Z")

</div>

Quite a few things have changed in the past four years since I wrote that  
blog post, such as more options in the function score query and field norms  
have more precision besides a single byte in Lucene. But ultimately, such  
logic does not belong in TD-IDF/BM-25, but outside of it. Besides, with  
function scores, you can change the boost level on the fly whenever you  
create the query. Waaaaay easier to A/B test different values.

---

<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: [April 3, 2018, 9:50pm UTC](https://discuss.elastic.co/t/assign-boost-to-document-at-index-time/122690/8 "2018-04-03T21:50:51Z")

</div>

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