# Document with weighted field values

**URL:** <https://discuss.elastic.co/t/document-with-weighted-field-values/126734>\
**Category:** Elasticsearch\
**Created:** [April 4, 2018, 11:53am UTC](https://discuss.elastic.co/t/document-with-weighted-field-values/126734 "2018-04-04T11:53:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aclowkey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclowkey/32/51020_2.png) [@aclowkey](https://discuss.elastic.co/u/aclowkey)\
**Post date:** [April 4, 2018, 11:53am UTC](https://discuss.elastic.co/t/document-with-weighted-field-values/126734/1 "2018-04-04T11:53:57Z")

</div>

Let's say that every document has multiple values, the values sort of probabilistic-ally define the document.  
So if a document has many `color` values of `red` and few of `white`, I would like to get documents based on how red they are.  
Now I also want to support synonyms. So, for example, I might say that velvet is a synonym for red, and the "red-ness" of a document would be also its "velvet-ness"

Now, I tried two approaches to these and I got stuck on each one.  
Approach 1 : Multisets  
Pros: Can use a field value factor of the field "color."  
Cons: This won't work for synonyms unless I expand them pre-query  
{  
"color":{  
"red":0.75,  
"white":0.25  
}  
}

Approach 2: Key Value  
Pros: Synonyms for color.value will work  
Cons: there's an ambiguous color.rank, which weight to use? 0.25 or 0.75? It's the same field  
{  
"color":[  
{"value":"red","weight":0.75},  
{"value":"white","weight":0.25}  
]  
}

Is there another approach for this? Thanks

---

<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:** [May 2, 2018, 11:53am UTC](https://discuss.elastic.co/t/document-with-weighted-field-values/126734/2 "2018-05-02T11:53:58Z")

</div>

Closed on May 2, 2018, 11:53am UTC

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