# Multi-value field scoring

**URL:** <https://discuss.elastic.co/t/multi-value-field-scoring/10024>\
**Category:** Elasticsearch\
**Created:** [December 10, 2012, 11:39pm UTC](https://discuss.elastic.co/t/multi-value-field-scoring/10024 "2012-12-10T23:39:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![y\_itay](https://avatars.discourse-cdn.com/v4/letter/y/76d3ee/32.png) [@y\_itay](https://discuss.elastic.co/u/y_itay)\
**Post date:** [December 10, 2012, 11:39pm UTC](https://discuss.elastic.co/t/multi-value-field-scoring/10024/1 "2012-12-10T23:39:06Z")

</div>

Hey,

I'm trying to find a way in ES or in Lucene to change the scoring of a multi-value field.  
Today it looks like that the multi-value field is being treated as bag of words.  
I want to be able to calculate the score per each value in the multi-value and use the max scored value in the document score at the end.

For example:

1. id: 1, Title: "new Sony Playstation", "ps 3", "game console for TV"
2. id: 2, Title: "Sony Playstation", "console game 3", "brand new Playstation 3"
3. id: 3, Title: "Brand sony console", "Best console sony playstation", "new sony playstation 3"

Input keywords: "sony, "new", "playstation"  
The order of the result should be: #1, #2, #3

ES will return the results as follow because #2, #3 has more keywords and #1 has other keywords in the title which aren't relevant to what I'm searching:  
id: 2, Title: Sony Playstation, console game 3, brand new Playstation 3  
id: 3, Title: Brand sony console, Best console sony playstation, new sony playstation 3  
id: 1, Title: new Sony Playstation, ps 3, game console for TV

Is there any specific query or customization I can do in order to change the scoring? The only way I thought about is to break these title into different documents which doesn't look like the best solution but it seemed like there is no other option.

Thanks,  
Itay

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 11, 2012, 4:18pm UTC](https://discuss.elastic.co/t/multi-value-field-scoring/10024/2 "2012-12-11T16:18:09Z")

</div>

The problem here is that all three element of the Title array are indexed  
as a single Title field. From the search perspective, the first record  
is equivalent to

id: 1, Title: "new Sony Playstation ps 3 game console for TV"

The only control that you have is setting position\_offset\_gap which  
specifies distance between instances of the same field. So, by setting it  
to 10, for example, you can specify that the word "ps" will be 10 words  
apart from the word "Playstation" in the first document and then you can  
use the slop\_near queries wrapped into custom\_filter\_score quires to boost  
the terms that occur near each other. However, you would have to create  
slop\_near for every pair, which might be cumbersome and slow.

A better solution would be to index titles as nested documents and use  
nested\_query with score\_mode set to max.

On Monday, December 10, 2012 6:39:06 PM UTC-5, itay yahimovitz wrote:

> Hey,
> 
> I'm trying to find a way in ES or in Lucene to change the scoring of a  
> multi-value field.  
> Today it looks like that the multi-value field is being treated as bag of  
> words.  
> I want to be able to calculate the score per each value in the multi-value  
> and use the max scored value in the document score at the end.
> 
> For example:
> 
> 1. id: 1, Title: "new Sony Playstation", "ps 3", "game console for TV"
> 2. id: 2, Title: "Sony Playstation", "console game 3", "brand new  
> Playstation 3"
> 3. id: 3, Title: "Brand sony console", "Best console sony playstation",  
> "new  
> sony playstation 3"
> 
> Input keywords: "sony, "new", "playstation"  
> The order of the result should be: #1, #2, #3
> 
> ES will return the results as follow because #2, #3 has more keywords and  
> #1  
> has other keywords in the title which aren't relevant to what I'm  
> searching:  
> id: 2, Title: Sony Playstation, console game 3, brand new Playstation 3  
> id: 3, Title: Brand sony console, Best console sony playstation, new sony  
> playstation 3  
> id: 1, Title: new Sony Playstation, ps 3, game console for TV
> 
> Is there any specific query or customization I can do in order to change  
> the  
> scoring? The only way I thought about is to break these title into  
> different  
> documents which doesn't look like the best solution but it seemed like  
> there  
> is no other option.
> 
> Thanks,  
> Itay
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Multi-value-field-scoring-tp4026784.html](http://elasticsearch-users.115913.n3.nabble.com/Multi-value-field-scoring-tp4026784.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--

---

<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:00am UTC](https://discuss.elastic.co/t/multi-value-field-scoring/10024/3 "2017-07-06T03:00:15Z")

</div>


