# Field value is auto-resorted while being called from scriptFunction()?

**URL:** <https://discuss.elastic.co/t/field-value-is-auto-resorted-while-being-called-from-scriptfunction/23435>\
**Category:** Elasticsearch\
**Created:** [April 28, 2015, 12:11pm UTC](https://discuss.elastic.co/t/field-value-is-auto-resorted-while-being-called-from-scriptfunction/23435 "2015-04-28T12:11:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yu\_Qian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yu_qian/32/734_2.png) [@Yu\_Qian](https://discuss.elastic.co/u/Yu_Qian)\
**Post date:** [April 28, 2015, 12:11pm UTC](https://discuss.elastic.co/t/field-value-is-auto-resorted-while-being-called-from-scriptfunction/23435/1 "2015-04-28T12:11:29Z")

</div>

Hi,

in my example, the value of my field "vectors" is an array. the mapping  
looks like this.

```
 "vectors": {        

  "type": "float",

      "index": "not_analyzed"

    }

```

for example, when I query a document by its id, part of the result might  
look like this,

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* "vectors":[3.2, 1.5, 2.2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*

I want to use my own score function for termQuery, which is implemented in  
a groovy script

however I got this in Groovy....

```
  doc['vectors'].values[0] = 1.5, doc['vectors'].values[1] = 2.2, ...

```

How do I fix it to keep the original order ?? such that  
doc['vectors'].values[0] = 3.2

I'm very desperate with this scripting now ... help needed !

Thanks.

--  
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/55e8700d-317f-46ba-83f9-2b9ef536ecca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/55e8700d-317f-46ba-83f9-2b9ef536ecca%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, 12:17am UTC](https://discuss.elastic.co/t/field-value-is-auto-resorted-while-being-called-from-scriptfunction/23435/2 "2017-07-06T00:17:26Z")

</div>


