# Storing all term positions in an array?

**URL:** <https://discuss.elastic.co/t/storing-all-term-positions-in-an-array/22083>\
**Category:** Elasticsearch\
**Created:** [February 11, 2015, 4:47am UTC](https://discuss.elastic.co/t/storing-all-term-positions-in-an-array/22083 "2015-02-11T04:47:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Panzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/panzer/32/927_2.png) [@Panzer](https://discuss.elastic.co/u/Panzer)\
**Post date:** [February 11, 2015, 4:47am UTC](https://discuss.elastic.co/t/storing-all-term-positions-in-an-array/22083/1 "2015-02-11T04:47:33Z")

</div>

This is a part of a groovy code that I wrote to get term positions:

for (pair in pairs) { // pairs is an array of pairs of terms  
def (value1, value2) = pair.tokenize(' ');  
def pos\_w1;  
def pos\_w2;  
for (pos in \_index["data"].get(value1, \_POSITIONS)) {  
pos\_w1 = pos.position;  
}  
for (pos in \_index["data"].get(value2, \_POSITIONS)) {  
pos\_w2 = pos.position;  
}}

I want it to work this way:

pairs = ['word1 word2', 'word3 word4']  
iteration 1:  
word1 : [2, 3]  
word2 : [6, 7, 8, 13]  
word1 : [45, 64]  
word2 : [46, 67, 87, 90]

I want to create an array of positions of value1 and one array of positions  
of value1. How can I do that?

--  
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/484bde40-e692-454b-a1ad-20966b49974a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/484bde40-e692-454b-a1ad-20966b49974a%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:33am UTC](https://discuss.elastic.co/t/storing-all-term-positions-in-an-array/22083/2 "2017-07-06T00:33:45Z")

</div>

Closed on July 6, 2017, 12:33am UTC


