Reputation: 139
I'm a fresh bee in elastic search and I'm trying to query documents from elastic search with aggregation. The query looks like this:
{
"size": 25000,
"query": {
"filtered": {
"query": {
"bool": {
"must_not": {
"term": {
"vlanId": [
2,
4,
8,
12,
16,
28,
0,
20,
24,
44,
544
]
}
}
}
},
"filter": {
"bool": {
"must": {
"exists": {
"field": "ipv4"
}
}
}
}
}
},
"aggregations": {
"vlan_ids": {
"terms": {
"field": "vlanId"
},
"aggregations": {
"top": {
"top_hits": {
"from": 0,
"size": 10,
"explain": true
}
}
}
}
}
}
After the execution, I'm getting Failed to execute phase [query], all shards failed
exception. I'm using Java API and elasticsearch 1.4v. Any lead is much appreciated.
Here is the sample JSON:
{ "_index":"vlan-active", "_source":{ "vlanId":8, "port":3, "vlanIP":"10.16.8.102", "ipv4":"10.16.8.102", "ipv6":"", "mac":"", "vendorName":"","os":""}}
Upvotes: 2
Views: 122
Reputation: 139
term
query will match field to a single value.
In order to match multiple values like in clause
, terms
should be used instead of term
.
I changed the keyword term
to terms
and got it working.
Upvotes: 2
Reputation: 4818
Your query starts and end with square brackets ("[]"), that is why it is not working. DSL queries should start with curly braces (i.e. "{}")
Edit: Removed the confusion due to my rhetorical question
Upvotes: 0