2

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":""}}
3
  • Can you include your index configuration? Sample data? Commented Mar 2, 2017 at 13:33
  • Wasn't there any cause for the exception? Commented Mar 2, 2017 at 15:33
  • @TIM: Added the sample JSON. Commented Mar 3, 2017 at 6:02

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

4 Comments

It was a rhetorical question as given his query it's not possible to run. Fair point though, since it is confusing I'll edit it
Edited my post to clarify that it is an answer
@clearlight: Fair enough, I started being active recently, I'm not 100% on the rules. Thanks for your clarification!
toString() method added the sqaure brackets! Sorry, my bad! With cutly braces also, the query is not working.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.