# Decay scale depending on a field

**URL:** <https://discuss.elastic.co/t/decay-scale-depending-on-a-field/24706>\
**Category:** Elasticsearch\
**Created:** [July 1, 2015, 10:05am UTC](https://discuss.elastic.co/t/decay-scale-depending-on-a-field/24706 "2015-07-01T10:05:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mykola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mykola/32/3532_2.png) [@mykola](https://discuss.elastic.co/u/mykola)\
**Post date:** [July 1, 2015, 10:05am UTC](https://discuss.elastic.co/t/decay-scale-depending-on-a-field/24706/1 "2015-07-01T10:05:35Z")

</div>

I have three groups of docs (e.g. docs from registered, verified and unregistered users), and I want to score them using decay function.

However, I need to have different speed of decay (scale) for each of this three groups of documents, so that docs from verified users were around the top longer than docs from unregistered users.

It seems, it is not possible to use doc field as a parameter for a decay function. Maybe, there is some other way to achieve what I want, like writing custom scoring function?

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [July 1, 2015, 11:25am UTC](https://discuss.elastic.co/t/decay-scale-depending-on-a-field/24706/2 "2015-07-01T11:25:40Z")

</div>

`function_score` allows you to only apply a function to a subset of your documents matching a given filter. So you should be able to do what you want by having 3 functions that apply a decay and each apply to a different subset of your index?

---

<div class="post-metadata">

**Author:** ![mykola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mykola/32/3532_2.png) [@mykola](https://discuss.elastic.co/u/mykola)\
**Post date:** [July 1, 2015, 12:02pm UTC](https://discuss.elastic.co/t/decay-scale-depending-on-a-field/24706/3 "2015-07-01T12:02:17Z")

</div>

Looks like it is really what I need. I don't know why I failed to notice "filter" in function\_score.

Thanks a lot!

---

<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 6, 2017, 12:04am UTC](https://discuss.elastic.co/t/decay-scale-depending-on-a-field/24706/4 "2017-07-06T00:04:16Z")

</div>


