Skip to content

Instantly share code, notes, and snippets.

@abronner
Created April 7, 2014 12:35
Show Gist options
  • Save abronner/10019478 to your computer and use it in GitHub Desktop.
Save abronner/10019478 to your computer and use it in GitHub Desktop.
elasticsearch (1.0.1) multi-field terms facet counts the same document twice
# reproduced with elasticsearch 1.0.1:
# index a document with 2 fields, both with the same value (the index will be implicitly generated)
curl -XPOST 'http://localhost:9200/test/test/2' -d '{
"first_name": "Rochelle",
"last_name": "Rochelle"
}'
# multi-field terms facet counts the document twice ('count = 2' for the term 'Rochelle')
curl 'http://localhost:9200/test/_search?pretty' -d '{
"size": 0,
"query": {
"match_all": {}
},
"facets": {
"names": {
"terms": {
"fields": ["first_name", "last_name"]
}
}
}
}'
# terms facet result:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.0,
"hits" : [ ]
},
"facets" : {
"names" : {
"_type" : "terms",
"missing" : 0,
"total" : 2,
"other" : 0,
"terms" : [ {
"term" : "rochelle",
"count" : 2
} ]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment