# Custom score script not 'seeing' all items in MultiValueField

**URL:** <https://discuss.elastic.co/t/custom-score-script-not-seeing-all-items-in-multivaluefield/14000>\
**Category:** Elasticsearch\
**Created:** [October 17, 2013, 7:49pm UTC](https://discuss.elastic.co/t/custom-score-script-not-seeing-all-items-in-multivaluefield/14000 "2013-10-17T19:49:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davecm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davecm/32/2038_2.png) [@davecm](https://discuss.elastic.co/u/davecm)\
**Post date:** [October 17, 2013, 7:49pm UTC](https://discuss.elastic.co/t/custom-score-script-not-seeing-all-items-in-multivaluefield/14000/1 "2013-10-17T19:49:15Z")

</div>

Hi,  
I created a simple custom\_score\_script that looks at a MultiValueField  
(tags), and if it finds the query (lets say a single word) inside of the  
list of tags, it adds ".05" onto the document score.

What I've found is that it is only working on some of the values inside of  
the MultiValueField.  
For example, if the field contains ['door', 'table', 'ring'], the script  
may only increase the score on ring and table... its completely random  
object to object.

I have some examples showing whats going on along with the simple custom  
score script (python).  
[http://dpaste.com/1420440/](http://dpaste.com/1420440/)

Any help is much appreciated it... its such a simple script - its killing  
me that I can't figure this odd behavior out.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![davecm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davecm/32/2038_2.png) [@davecm](https://discuss.elastic.co/u/davecm)\
**Post date:** [October 17, 2013, 7:52pm UTC](https://discuss.elastic.co/t/custom-score-script-not-seeing-all-items-in-multivaluefield/14000/2 "2013-10-17T19:52:53Z")

</div>

Sorry - realized my comments were a bit off. here is the updated  
sample: [http://dpaste.com/1420446/](http://dpaste.com/1420446/)

On Thursday, October 17, 2013 3:49:15 PM UTC-4, Dave Brown wrote:

> Hi,  
> I created a simple custom\_score\_script that looks at a MultiValueField  
> (tags), and if it finds the query (lets say a single word) inside of the  
> list of tags, it adds ".05" onto the document score.
> 
> What I've found is that it is only working on some of the values inside of  
> the MultiValueField.  
> For example, if the field contains ['door', 'table', 'ring'], the script  
> may only increase the score on ring and table... its completely random  
> object to object.
> 
> I have some examples showing whats going on along with the simple custom  
> score script (python).  
> [http://dpaste.com/1420440/](http://dpaste.com/1420440/)
> 
> Any help is much appreciated it... its such a simple script - its killing  
> me that I can't figure this odd behavior out.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Britta\_Weber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/britta_weber/32/1113_2.png) [@Britta\_Weber](https://discuss.elastic.co/u/Britta_Weber)\
**Post date:** [October 19, 2013, 2:39pm UTC](https://discuss.elastic.co/t/custom-score-script-not-seeing-all-items-in-multivaluefield/14000/3 "2013-10-19T14:39:12Z")

</div>

Hi Dave,

unless I misunderstood what you were trying to do, I suspect that  
there is a problem in your script. Searching for terms in a multi  
valued field and scoring accordingly seems to run fine using a mvel  
script like here: [function score example that checks for words in a multi valued field and adds 1 if the word was found. · GitHub](https://gist.github.com/brwe/7056487).

Could you provide a full running example (including imports, mapping,  
data init, function definitions and so forth) that reproduces the  
behavior?

Cheers,  
Britta

On Thu, Oct 17, 2013 at 9:52 PM, Dave Brown [dave@custommade.com](mailto:dave@custommade.com) wrote:

> Sorry - realized my comments were a bit off. here is the updated sample:  
> [http://dpaste.com/1420446/](http://dpaste.com/1420446/)
> 
> On Thursday, October 17, 2013 3:49:15 PM UTC-4, Dave Brown wrote:
> 
> > Hi,  
> > I created a simple custom\_score\_script that looks at a MultiValueField  
> > (tags), and if it finds the query (lets say a single word) inside of the  
> > list of tags, it adds ".05" onto the document score.
> > 
> > What I've found is that it is only working on some of the values inside of  
> > the MultiValueField.  
> > For example, if the field contains ['door', 'table', 'ring'], the script  
> > may only increase the score on ring and table... its completely random  
> > object to object.
> > 
> > I have some examples showing whats going on along with the simple custom  
> > score script (python).  
> > [http://dpaste.com/1420440/](http://dpaste.com/1420440/)
> > 
> > Any help is much appreciated it... its such a simple script - its killing  
> > me that I can't figure this odd behavior out.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:11am UTC](https://discuss.elastic.co/t/custom-score-script-not-seeing-all-items-in-multivaluefield/14000/4 "2017-07-06T02:11:38Z")

</div>


