Hey ES Gurus,
I been trying to generate reports from es documents in kibana. Below is the sample
{
"customer" :
"contact":
{
"phones" : [
{
"category":"personal",
"number":"1111111111"
},
{
"category":"work",
"number":"2222222222"
}
]
}
}
When i use painless script as below
doc["customer.contact.phones.category.keyword"].values + ':' +doc["customer.contact.phones.number.keyword"].values
The output goes as
["personal","work"] , ["111111111","2222222222"]
in the discover module.
I am anticipating the output as below and have implemented painless script
["personal:"1111111111"] ,
["work":"2222222222"]
Then i tried using painless loop as below in the scripted field text box and seeing the error. Please help me out
for(int i=0; doc["customer.contact.phones.number.keyword"].length;i++){
doc["customer.contact.phones.category.keyword"][i].value +':'+
doc["customer.contact.phones.number.keyword"][i]
.value}
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":["... r.keyword\"].length;i++){\ndoc[\"LiveFeed.customer.pr ..."," ^---- HERE"],"script":"for(int i=0; doc[\"customer.contact.phones.number.keyword\"].length;i++){\ndoc[\"customer.contact.phones.category.keyword\"][i].value +':'+ \ndoc[\"customer.contact.phones.number.keyword\"][i]\n.value}","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"cem-profile-index","node":"rN4VSEjiREi6T-LofTIH2A","reason":{"type":"script_exception","reason":"compile error","script_stack":["... r.keyword\"].length;i++){\ndoc[\"LiveFeed.customer.pr ..."," ^---- HERE"],"script":"for(int i=0; doc[\"customer.contact.phones.number.keyword\"].length;i++){\ndoc[\"customer.contact.phones.category.keyword\"][i].value +':'+ \ndoc[\"customer.contact.phones.number.keyword\"][i]\n.value}","lang":"painless","caused_by":{**"type":"illegal_argument_exception","reason":"Not a statement."**}}}]},"status":500}