I have a query that works fine when I run it using _search, but it fails when using _count. Can someone tell me why? I'd rather not have to run the complete query just to get a count.
This is the query.
{
"filter": {
"nested": {
"filter": {
"bool": {
"must": [
{
"term": {
"user_id": 5
}
}
]
}
},
"path": "participants"
}
}
}
This is the failure:
{
"count": 0,
"_shards": {
"total": 5,
"successful": 0,
"failed": 5,
"failures": [
{
"index": "messages_20150428_000025",
"shard": 0,
"reason": "BroadcastShardOperationFailedException[[messages_20150428_000025][0] ]; nested: QueryParsingException[[messages_20150428_000025] request does not support [filter]]; "
},
{
"index": "messages_20150428_000025",
"shard": 1,
"reason": "BroadcastShardOperationFailedException[[messages_20150428_000025][1] ]; nested: QueryParsingException[[messages_20150428_000025] request does not support [filter]]; "
},
{
"index": "messages_20150428_000025",
"shard": 2,
"reason": "BroadcastShardOperationFailedException[[messages_20150428_000025][2] ]; nested: QueryParsingException[[messages_20150428_000025] request does not support [filter]]; "
},
{
"index": "messages_20150428_000025",
"shard": 3,
"reason": "BroadcastShardOperationFailedException[[messages_20150428_000025][3] ]; nested: QueryParsingException[[messages_20150428_000025] request does not support [filter]]; "
},
{
"index": "messages_20150428_000025",
"shard": 4,
"reason": "BroadcastShardOperationFailedException[[messages_20150428_000025][4] ]; nested: QueryParsingException[[messages_20150428_000025] request does not support [filter]]; "
}
]
}
}
Given this the mapping for this nested field:
"participants": {
"type": "nested",
"properties": {
"archived": {
"type": "boolean"
},
"has_unread": {
"type": "boolean"
},
"name": {
"type": "string"
},
"pk": {
"type": "long"
},
"user_id": {
"type": "long"
}
}
},
and these data (for this nested field only):
"participants": [
{
"archived": false,
"user_id": 5,
"name": "Person A",
"has_unread": false,
"pk": 1
},
{
"archived": false,
"user_id": 7,
"name": "Person B",
"has_unread": false,
"pk": 2
}
],