I have the following index properties:
{
"mappings": {
"properties": {
"content": { "type": "text" },
"place": {
"type": "nested",
"properties": {
"home": {
"type": "text"
},
"work": {
"type": "text"
}
}
}
}
}
}
I want to get all the documents that contain more than one value of place field.
For example, if the index contains the following 2 documents:
{
"content": "First content",
"place": [
{
"home": "home_1",
"work": "work_1"
},
{
"home": "home_2",
"work": "home_2"
}
]
},
{
"content": "Second content",
"place": [
{
"home": "home_3",
"work": "work_3"
}
]
}
I want to write a query that gives us the first document (because it contains place field with an array of size 2).
I have tried:
"filter": {
"script": {
"script": "doc['place'].values.length > 1"
}
}
But I got error:
RequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [filter].')