I have following nested type mapping:
"visitor_data": {
"type": "nested",
"dynamic": "false",
"properties": {
"checkin_time": {
"type": "date",
"format": "epoch_second"
},
"completed_on": {
"type": "date",
"format": "epoch_second"
},
"edition_id": {
"type": "keyword"
},
"end_date": {
"type": "date",
"format": "date"
},
"event_id": {
"type": "keyword"
},
"evisitor": {
"type": "boolean"
},
"flag": {
"type": "byte"
},
"interest_date": {
"type": "date",
"format": "epoch_second"
},
"is_verified": {
"type": "boolean"
},
"post_status": {
"type": "byte"
},
"pre_status": {
"type": "byte"
},
"start_date": {
"type": "date",
"format": "date"
},
"status": {
"type": "byte"
},
"visitor_published": {
"type": "byte"
},
"visitor_score": {
"type": "byte"
}
}
}
I am trying to loop through this field in script but it seems i cant access it. please suggest a way of doing it. here is my script code :
"script_score": {
"script": {
"lang": "painless",
"source": """
int total = 0;
for (int i = 0; i < doc['visitor_data'].length; ++i)
{
total +=1;
}
return total;
"""
}
}