# Using term position to re-score

**URL:** <https://discuss.elastic.co/t/using-term-position-to-re-score/105415>\
**Category:** Elasticsearch\
**Created:** [October 26, 2017, 11:17am UTC](https://discuss.elastic.co/t/using-term-position-to-re-score/105415 "2017-10-26T11:17:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![angelcab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/angelcab/32/45618_2.png) [@angelcab](https://discuss.elastic.co/u/angelcab)\
**Post date:** [October 26, 2017, 11:17am UTC](https://discuss.elastic.co/t/using-term-position-to-re-score/105415/1 "2017-10-26T11:17:50Z")

</div>

Hi  
I'm trying to create a script to modify the score of my queries.  
I want to access the position of a word in the results I am obtaining.  
For example the word: "global" in the string name= "Global corporation". So I want to know that global is the position: 1  
I'm doing it with painless :

"functions": [  
{  
"script\_score": {  
"script": "doc['nombre'].get('Global',\_POSSITION)"  
}  
}  
]

But I am obtaining compling errors with : Possition. (Global is the word I want to know the possition). This is just a try to see if I can obtain the position of a word . I have performed

GET index/doc/1/termvectors?field=nombre

And I can see that the position of the tokens are stored there.

How can I acess that value in my script?

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:** [November 23, 2017, 11:18am UTC](https://discuss.elastic.co/t/using-term-position-to-re-score/105415/2 "2017-11-23T11:18:14Z")

</div>

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