Created
November 10, 2014 19:48
-
-
Save brusic/81e1552ffd49a1f6a7aa to your computer and use it in GitHub Desktop.
Nested aggregation issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -XPUT localhost:9200/test -d '{ | |
| "settings": { | |
| "index": { | |
| "number_of_shards": 1, | |
| "number_of_replicas": 0 | |
| } | |
| }, | |
| "mappings": { | |
| "test" : { | |
| "properties" : { | |
| "offers" : { | |
| "type" : "nested", | |
| "properties": { | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| ' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -XPUT localhost:9200/test/test/1 -d ' | |
| { | |
| "name" : "foo", | |
| "offers" : [ | |
| { | |
| "ID" : 1 | |
| } | |
| ] | |
| } | |
| ' | |
| curl -XPUT localhost:9200/test/test/2 -d ' | |
| { | |
| "name" : "bar", | |
| "offers" : [ | |
| { | |
| "ID" : 2 | |
| } | |
| ] | |
| } | |
| ' | |
| curl -XPUT localhost:9200/test/test/3 -d ' | |
| { | |
| "name" : "baz", | |
| "offers" : [ | |
| { | |
| "ID" : 1 | |
| }, | |
| { | |
| "ID" : 2 | |
| } | |
| ] | |
| } | |
| ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| POST test/test/_search | |
| { | |
| "size": 0, | |
| "query": { | |
| "filtered": { | |
| "query": { | |
| "match_all": {} | |
| }, | |
| "filter": { | |
| "nested": { | |
| "path": "offers", | |
| "filter": { | |
| "term": { | |
| "offers.ID": 1 | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "aggregations": { | |
| "Attempt1": { | |
| "nested": { | |
| "path": "offers" | |
| }, | |
| "aggs": { | |
| "ID": { | |
| "terms": { | |
| "field": "offers.ID" | |
| } | |
| } | |
| } | |
| }, | |
| "FilteredAttempt2": { | |
| "filter": { | |
| "nested": { | |
| "path": "offers", | |
| "filter": { | |
| "term": { | |
| "offers.ID": 1 | |
| } | |
| } | |
| } | |
| }, | |
| "aggs": { | |
| "NestedID": { | |
| "nested": { | |
| "path": "offers" | |
| }, | |
| "aggs": { | |
| "CatalogID": { | |
| "terms": { | |
| "field": "offers.ID" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment