# How to update integer like click count efficiently for ranking

**URL:** <https://discuss.elastic.co/t/how-to-update-integer-like-click-count-efficiently-for-ranking/63863>\
**Category:** Elasticsearch\
**Created:** [October 25, 2016, 11:46am UTC](https://discuss.elastic.co/t/how-to-update-integer-like-click-count-efficiently-for-ranking/63863 "2016-10-25T11:46:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fancyerii](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@fancyerii](https://discuss.elastic.co/u/fancyerii)\
**Post date:** [October 25, 2016, 11:46am UTC](https://discuss.elastic.co/t/how-to-update-integer-like-click-count-efficiently-for-ranking/63863/1 "2016-10-25T11:46:05Z")

</div>

I want to use a field to record the number of click of a document. it's not searched but only used to calculate the score. But it's updated frequently. How should I define the mapping of this field and how can I use this field to calculate score?

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [October 25, 2016, 12:04pm UTC](https://discuss.elastic.co/t/how-to-update-integer-like-click-count-efficiently-for-ranking/63863/2 "2016-10-25T12:04:19Z")

</div>

> [@fancyerii](#):
>
> But it's updated frequently

How frequent is frequently?

Why I'm asking this: Often at first sight implementing such a feature one would like to reflect the exact click count in the index. But looking at the feature again, it might be acceptable to update these clicks only every so often in bulk. Even from a user's perspective limiting the impact of single clicks might make sense - many people I know expect search results for the same query to remain constant within at least a short amount of time (between page reloads within seconds/minutes).

As for how to use something like this for scoring: I'd make sure to normalise clicks across documents instead of using raw counts. I'd think about fading out the impact of older clicks to avoid having older documents dominate searches just because they had more time to accumulate clicks. Depending on your use-case I'd spend some time thinking about how much of an incentive you are setting for people to spam this ranking signal.

> [@fancyerii](#):
>
> how can I use this field to calculate score

I'd probably get started with

> **[Function score query | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)**

Hope this helps,  
Isabel

---

<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:10pm UTC](https://discuss.elastic.co/t/how-to-update-integer-like-click-count-efficiently-for-ranking/63863/3 "2017-07-05T22:10:01Z")

</div>


