# Index list structure using Groovy API

**URL:** <https://discuss.elastic.co/t/index-list-structure-using-groovy-api/10965>\
**Category:** Elasticsearch\
**Created:** [March 1, 2013, 12:14pm UTC](https://discuss.elastic.co/t/index-list-structure-using-groovy-api/10965 "2013-03-01T12:14:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Parreira](https://avatars.discourse-cdn.com/v4/letter/d/b2d939/32.png) [@Daniel\_Parreira](https://discuss.elastic.co/u/Daniel_Parreira)\
**Post date:** [March 1, 2013, 12:14pm UTC](https://discuss.elastic.co/t/index-list-structure-using-groovy-api/10965/1 "2013-03-01T12:14:16Z")

</div>

Hello guys,

I'm looking forward to index a list using Elasticsearch Groovy API.

def indexR = client.index {  
index "test"  
type "type1"  
id "1"  
source {  
test = "value"  
complex {  
value1 = "value1"  
value2 = "value2"  
}  
list [{a},{b},{v}]  
}  
}  
}

for example, i've tried to build the index dynamically, using a for loop:

enderecos [  
for(int i = 0; i \< instituicaoInstance.enderecos; i++){  
Endereco enderecoInstance = instituicaoInstance.enderecos[i]  
{  
cep = "${enderecoInstance.cep}"  
logradouro = "${enderecoInstance.logradouro}"  
complemento = "${enderecoInstance.complemento}"  
bairro = "${enderecoInstance.bairro}"  
estado = "${enderecoInstance.estado}"  
cidade = "${enderecoInstance.cidade}"  
descricaoLocal = "${enderecoInstance.descricaoLocal}"  
latitude = "${enderecoInstance.latitude}"  
longitude = "${enderecoInstance.longitude}"  
}  
}]

But the closure won't accept a for loop in the middle of the process.

So how can i do it so?

Thanks alot,

Daniel Marchena

--  
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:48am UTC](https://discuss.elastic.co/t/index-list-structure-using-groovy-api/10965/2 "2017-07-06T02:48:51Z")

</div>

Closed on July 6, 2017, 2:48am UTC


