Skip to content

Instantly share code, notes, and snippets.

@jfiedler
Created May 23, 2011 11:04
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 jfiedler/986550 to your computer and use it in GitHub Desktop.
Save jfiedler/986550 to your computer and use it in GitHub Desktop.
Strange secondary sorting of Elastic Search TermsFacet entries with identical hit count
curl -XDELETE 'http://localhost:9200/test/'
curl -XPUT 'http://localhost:9200/test/'
curl -XPUT 'http://localhost:9200/test/test/1' -d '
{
"doc":{
"string" : "foo"
}
}
'
curl -XPUT 'http://localhost:9200/test/test/2' -d '
{
"doc":{
"string" : "bar"
}
}
'
curl -XGET 'http://localhost:9200/test/test/_search?pretty=true' -d '
{
"query" : {
"match_all" : {
}
},
"facets" : {
"myFacet" : {
"terms" : {
"field" : "doc.string",
"size" : 10,
"order" : "count"
}
}
}
}
'
#Response shows strange secondary sorting by term value
...
"facets" : {
"myFacet" : {
"_type" : "terms",
"missing" : 0,
"terms" : [ {
"term" : "foo",
"count" : 1
}, {
"term" : "bar",
"count" : 1
} ]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment