# Best approach to implement tag weights

**URL:** <https://discuss.elastic.co/t/best-approach-to-implement-tag-weights/53595>\
**Category:** Elasticsearch\
**Created:** [June 22, 2016, 2:34am UTC](https://discuss.elastic.co/t/best-approach-to-implement-tag-weights/53595 "2016-06-22T02:34:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)\
**Post date:** [June 22, 2016, 2:34am UTC](https://discuss.elastic.co/t/best-approach-to-implement-tag-weights/53595/1 "2016-06-22T02:34:32Z")

</div>

I have documents with tags and i have weights for each tag. There are more than 40 million documents in the index. I would like to boost the documents according to the tag weight. I can think of two ways to implement this idea.

1. index time: repeat the tags proportional to the weight in the index
2. search time: store tag string and weight as a nested document and use a function scoring query to boost the documents with matching tags by its weight.

Though I like 2nd approach for its flexibility and smaller index size, performance is always a crucial factor in search. I feel that first approach would be better in terms of performance though it looks like a hacked solution.

I am planning to do some benchmark testing myself, but I am curious to learn how others with similar use case handled the problem.

---

<div class="post-metadata">

**Author:** ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)\
**Post date:** [June 24, 2016, 10:42pm UTC](https://discuss.elastic.co/t/best-approach-to-implement-tag-weights/53595/2 "2016-06-24T22:42:52Z")

</div>

any suggestions from any one who handled this situation already ?

---

<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:** [July 5, 2017, 10:40pm UTC](https://discuss.elastic.co/t/best-approach-to-implement-tag-weights/53595/3 "2017-07-05T22:40:37Z")

</div>


