Hello! Is there a way to request a field in a normalized form?
For example, for a mapping {"mappings" : { "properties" : { "fieldA" : "integer"} } }
and indexed documents { "fieldA" : "42" }
and { "fieldA" : 43 }
, how can I get values of fieldA
in both documents as an integer?
You can use script_fields
to achieve that:
GET test11/_search
{
"script_fields": {
"a": {
"script": {
"lang": "expression",
"source": "doc['fieldA']"
}
}
}
}
1 Like
Thanks @gaobinlong !
Unfortunately, this doesn’t work with geo_point
.
I spent a lot of time of googling before, but today I got a very easy working solution:
{
"fields" : [
"fieldA"
],
"_source" : false
}
This works with both integer and geo_point types.
Anyway I much appreciate your time.
1 Like