# \[scripting score\] quick way to see if a value is or is not in a field of a type array

**URL:** <https://discuss.elastic.co/t/scripting-score-quick-way-to-see-if-a-value-is-or-is-not-in-a-field-of-a-type-array/19818>\
**Category:** Elasticsearch\
**Created:** [September 16, 2014, 3:09pm UTC](https://discuss.elastic.co/t/scripting-score-quick-way-to-see-if-a-value-is-or-is-not-in-a-field-of-a-type-array/19818 "2014-09-16T15:09:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicom/32/488_2.png) [@nicom](https://discuss.elastic.co/u/nicom)\
**Post date:** [September 16, 2014, 3:09pm UTC](https://discuss.elastic.co/t/scripting-score-quick-way-to-see-if-a-value-is-or-is-not-in-a-field-of-a-type-array/19818/1 "2014-09-16T15:09:35Z")

</div>

Hi guys,

I have objects with 3 fields of type array containing a large amount of  
integers.

these integers are mutually excluded between fields = if an integer is in  
the field1, it can't be in the field2 or field3, and vise-versa

for instance

object\_1: {  
field1: [1,4,5,8],  
field2: [2,6,7,11],  
field3: [3,9,10]  
}

object\_2: {  
field1: [1],  
field2: [3, 2, 4],  
field3: [10,7]  
}

since each field have a different importance (field1\> field2\> field3). I  
would to create a custom script scoring according the field in which the  
integer 6 is (for instance), like the following

if field1 has the integer 6 =\> score 2  
if field2 has the integer 6 =\> score 1  
if field3 has the integer 6 =\> score 0.5

How to effectively do that in scripting ?

I would like to avoid interating since the fields/arrays of some objects  
are very large (100K)

( boosting differently each field can be used to pre ranking the objects  
and retrieve the top N, but I need a more complex custom score as  
post-scoring)

Thanks in advance !

Nico

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bcca4bf6-58ab-4ab6-9bc7-23aa58752120%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bcca4bf6-58ab-4ab6-9bc7-23aa58752120%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:01am UTC](https://discuss.elastic.co/t/scripting-score-quick-way-to-see-if-a-value-is-or-is-not-in-a-field-of-a-type-array/19818/2 "2017-07-06T01:01:56Z")

</div>


