Skip to content

Instantly share code, notes, and snippets.

@huseyinbabal
Created November 5, 2012 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huseyinbabal/4015950 to your computer and use it in GitHub Desktop.
Save huseyinbabal/4015950 to your computer and use it in GitHub Desktop.
Elasticsearch subdocument facet count
curl -XPOST http://localhost:9200/my/terms/_search?pretty=true -d '
{
"query" : { "wildcard" : {"term" : "fire"} },
"facets" : {
"langs" : { "terms" : {"field" : "translations.lang"} }
}
}
'
Result:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "my",
"_type" : "terms",
"_id" : "5097715abacf848020000010",
"_score" : 1.0, "_source" : {"lang":"en","term":"fire","translations":[{"_id":"5097715abacf848020000011","lang":"tr","translation":"ateş","score":"0","createDate":"2012-11-05T07:57:14.659Z","author":"anonymous"},{"_id":"50977160bacf848020000015","lang":"tr","translation":"duman","score":"0","createDate":"2012-11-05T07:57:20.470Z","author":"anonymous"}],"author":"anonymous","createDate":"2012-11-05T07:57:14.658Z"}
} ]
},
"facets" : {
"langs" : {
"_type" : "terms",
"missing" : 0,
"total" : 1,
"other" : 0,
"terms" : [ {
"term" : "tr",
"count" : 1
} ]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment