Skip to content

Instantly share code, notes, and snippets.

@jessejlt
Created January 25, 2012 01:29
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 jessejlt/1674000 to your computer and use it in GitHub Desktop.
Save jessejlt/1674000 to your computer and use it in GitHub Desktop.
# nuke the database
curl -XDELETE localhost:9200/test
# post 3 items, 2 of which have the same <type>
curl -XPOST localhost:9200/test/item -d '
{
"color": "yellow",
"type": "crayon"
}'
curl -XPOST localhost:9200/test/item -d '
{
"color": "blue",
"type": "crayon"
}'
curl -XPOST localhost:9200/test/item -d '
{
"color": "red",
"type": "paint"
}'
# refresh the db
curl -XPOST localhost:9200/test/_refresh
# get facets for <color> but only for <type> = <paint>
curl -XGET localhost:9200/test/item/_search?pretty=true -d '
{
"query": {
"match_all": {}
},
"facets": {
"response": {
"terms": {
"field": "color"
}
},
"facet_filter": {
"term": {
"type": "paint"
}
}
}
}'
# I would expect a result along the lines of
"facets" : {
"response" : {
"_type" : "terms",
"missing" : 2,
"total" : 1,
"other" : 0,
"terms" : [ {
"term" : "red",
"count" : 1
} ]
}
}
# but instead I get an error
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[zJM81u34Qxyz4Dt0QWeoDg][test][3]: SearchParseException[[test][3]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"query\": {\n\"match_all\": {}\n},\n\"facets\": {\n\"response\": {\n\"terms\": {\n\"field\": \"color\"\n}\n},\n\"facet_filter\": {\n\"term\": {\n\"type\": \"paint\"\n}\n}\n}\n}]]]; nested: SearchParseException[[test][3]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No facet type found for [term]]]; }{[zJM81u34Qxyz4Dt0QWeoDg][test][2]: SearchParseException[[test][2]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"query\": {\n\"match_all\": {}\n},\n\"facets\": {\n\"response\": {\n\"terms\": {\n\"field\": \"color\"\n}\n},\n\"facet_filter\": {\n\"term\": {\n\"type\": \"paint\"\n}\n}\n}\n}]]]; nested: SearchParseException[[test][2]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No facet type found for [term]]]; }{[zJM81u34Qxyz4Dt0QWeoDg][test][4]: SearchParseException[[test][4]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"query\": {\n\"match_all\": {}\n},\n\"facets\": {\n\"response\": {\n\"terms\": {\n\"field\": \"color\"\n}\n},\n\"facet_filter\": {\n\"term\": {\n\"type\": \"paint\"\n}\n}\n}\n}]]]; nested: SearchParseException[[test][4]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No facet type found for [term]]]; }{[zJM81u34Qxyz4Dt0QWeoDg][test][3]: SearchParseException[[test][3]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"query\": {\n\"match_all\": {}\n},\n\"facets\": {\n\"response\": {\n\"terms\": {\n\"field\": \"color\"\n}\n},\n\"facet_filter\": {\n\"term\": {\n\"type\": \"paint\"\n}\n}\n}\n}]]]; nested: SearchParseException[[test][3]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No facet type found for [term]]]; }{[zJM81u34Qxyz4Dt0QWeoDg][test][4]: SearchParseException[[test][4]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"query\": {\n\"match_all\": {}\n},\n\"facets\": {\n\"response\": {\n\"terms\": {\n\"field\": \"color\"\n}\n},\n\"facet_filter\": {\n\"term\": {\n\"type\": \"paint\"\n}\n}\n}\n}]]]; nested: SearchParseException[[test][4]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No facet type found for [term]]]; }]",
"status" : 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment