I need a help about getting an array item with indice ([0] e.g.) in elasticsearch. Whatever painless or scriptless behaviour.
Here is my little test mapping, document and results;
"mappings": {
"tip": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"props": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
And I indexed one document like that;
{
"name": "burak",
"props": [
"4",
"2",
"3"
]
}
When I get "props" values with painless script the values of props fetched as ordered. I don't want this, how can I fix it ?
{
"script_fields": {
"FIELD": {
"script": {
"inline": "doc['props.keyword']",
"lang": "painless"
}
}
}
}
The result was;
"fields": {
"FIELD": [
"2",
"3",
"4"
]
}