Index list structure using Groovy API

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
For more options, visit