# Dynamic ranking depending on value of multiple field

**URL:** <https://discuss.elastic.co/t/dynamic-ranking-depending-on-value-of-multiple-field/8716>\
**Category:** Elasticsearch\
**Created:** [August 11, 2012, 9:45am UTC](https://discuss.elastic.co/t/dynamic-ranking-depending-on-value-of-multiple-field/8716 "2012-08-11T09:45:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabik\_2](https://avatars.discourse-cdn.com/v4/letter/f/a8b319/32.png) [@fabik\_2](https://discuss.elastic.co/u/fabik_2)\
**Post date:** [August 11, 2012, 9:45am UTC](https://discuss.elastic.co/t/dynamic-ranking-depending-on-value-of-multiple-field/8716/1 "2012-08-11T09:45:06Z")

</div>

Hello,

i've been trying for hours now but i can't come up with a good solution for  
the problem. Seems like nobody has had a similiar problem yet:

I have a large database of products and i have a database of product\_tags.

{'id\_item' =\> 1, 'title' =\> 'PS3 Game A', 'tags' =\> {{'tag' =\> 'ps3',  
'boost' =\> 3}, {'tag' =\> 'xbox', 'boost' =\> 2}}  
{'id\_item' =\> 2, 'title' =\> 'PS3 Game B', 'tags' =\> {{'tag' =\> 'ps3',  
'boost' =\> 2}, {'tag' =\> 'xbox', 'boost' =\> 3}}

What's supposed to happen is, when somebody searches for ps3 i want the  
id\_item=1 item to be boosted higher that the second, for xbox the id\_item=2  
should be boosted stronger.  
So i looked at boosting, parent/child, objects but i think nothing really  
fulfills my needs. Has anybody an idea of handling this?

Thanks a lot!

--

---

<div class="post-metadata">

**Author:** ![Chris\_Male](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_male/32/2607_2.png) [@Chris\_Male](https://discuss.elastic.co/u/Chris_Male)\
**Post date:** [August 12, 2012, 4:06am UTC](https://discuss.elastic.co/t/dynamic-ranking-depending-on-value-of-multiple-field/8716/2 "2012-08-12T04:06:59Z")

</div>

I can see a couple of options:

- Denormalize your data even more so each document in ES consists of the  
data for a single tag. This would mean your id\_item and title would be  
repeated (potentially a lot if you have a lot of tags) but you could then  
have the boost for the document be the boost for the tag. There could be  
issues of repetition of results but you might be able to get around that,  
depending in your requirements.
- Use a custom\_score query with a script to implement your more complex  
scoring.

On Saturday, August 11, 2012 9:45:06 PM UTC+12, fabik wrote:

> Hello,
> 
> i've been trying for hours now but i can't come up with a good solution  
> for the problem. Seems like nobody has had a similiar problem yet:
> 
> I have a large database of products and i have a database of product\_tags.
> 
> {'id\_item' =\> 1, 'title' =\> 'PS3 Game A', 'tags' =\> {{'tag' =\> 'ps3',  
> 'boost' =\> 3}, {'tag' =\> 'xbox', 'boost' =\> 2}}  
> {'id\_item' =\> 2, 'title' =\> 'PS3 Game B', 'tags' =\> {{'tag' =\> 'ps3',  
> 'boost' =\> 2}, {'tag' =\> 'xbox', 'boost' =\> 3}}
> 
> What's supposed to happen is, when somebody searches for ps3 i want the  
> id\_item=1 item to be boosted higher that the second, for xbox the id\_item=2  
> should be boosted stronger.  
> So i looked at boosting, parent/child, objects but i think nothing really  
> fulfills my needs. Has anybody an idea of handling this?
> 
> 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, 3:16am UTC](https://discuss.elastic.co/t/dynamic-ranking-depending-on-value-of-multiple-field/8716/3 "2017-07-06T03:16:41Z")

</div>


