Skip to content

Instantly share code, notes, and snippets.

@marek-obuchowicz
Created March 8, 2014 14:16
Show Gist options
  • Save marek-obuchowicz/9431175 to your computer and use it in GitHub Desktop.
Save marek-obuchowicz/9431175 to your computer and use it in GitHub Desktop.
Different result for Aggregations vs Facets (terms):
$ curl 'http://127.0.0.1:9200/catalog_links/catalog_link/_search?pretty&search_type=count' -d '{"query":{"match_all":{}},"facets":{"tags":{"terms":{"field":"tags"}}}}'
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 0.0,
"hits" : [ ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 17,
"other" : 5,
"terms" : [ {
"term" : "tag1",
"count" : 2
}, {
"term" : "else",
"count" : 2
}, {
"term" : "thingy",
"count" : 1
}, {
"term" : "thing",
"count" : 1
}, {
"term" : "tag4",
"count" : 1
}, {
"term" : "tag34",
"count" : 1
}, {
"term" : "tag2",
"count" : 1
}, {
"term" : "tag",
"count" : 1
}, {
"term" : "something",
"count" : 1
}, {
"term" : "some",
"count" : 1
} ]
}
}
}
$ curl 'http://127.0.0.1:9200/catalog_links/catalog_link/_search?pretty&search_type=count' -d '{"query":{"match_all":{}},"aggregations":{"tags":{"terms":{"field":"tags"}}}}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"tags" : {
"buckets" : [ {
"key" : "else",
"doc_count" : 2
}, {
"key" : "tag1",
"doc_count" : 2
}, {
"key" : "4",
"doc_count" : 1
}, {
"key" : "5",
"doc_count" : 1
}, {
"key" : "6",
"doc_count" : 1
}, {
"key" : "long",
"doc_count" : 1
}, {
"key" : "name",
"doc_count" : 1
}, {
"key" : "some",
"doc_count" : 1
}, {
"key" : "something",
"doc_count" : 1
}, {
"key" : "tag",
"doc_count" : 1
} ]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment