Skip to content

Instantly share code, notes, and snippets.

@ctrochalakis
Created March 13, 2012 13:36
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 ctrochalakis/d2a223467c9e266b0ce0 to your computer and use it in GitHub Desktop.
Save ctrochalakis/d2a223467c9e266b0ce0 to your computer and use it in GitHub Desktop.
elastic faceting issue
$ cat faceting.txt
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"term": {
"visible": true
}
}
}
},
"facets": {
"fg_42649": {
"terms": {
"field": "filters.fg_42649"
}
}
}
}
$ curl -XPOST http://localhost:9200/category_1087/_search?pretty -d @faceting.txt
{
"error" : "SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[g7uRjzXeQeunobiTvF2HgQ][skus][0]: QueryPhaseExecutionException[[skus][0]: query[ConstantScore(NotDeleted(cache(visible:T)))],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: ClassCastException[org.elasticsearch.index.field.data.strings.SingleValueStringFieldData cannot be cast to org.elasticsearch.index.field.data.longs.LongFieldData]; }]",
"status" : 500
}
The error doesn't occur if I remove the facet and redo the query.
$ curl http://localhost:9200/category_1087/_search?pretty -d '{"query" : {"match_all": {}}}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "skus",
"_type" : "sku",
"_id" : "442189",
"_score" : 1.0, "_source" : {"display_name":"foo","manufacturer_id":0,"price":5400,"popularity":0,"visible":"true","filters":{"fg_42649":[309394]}}
} ]
}
}
$ curl -s http://localhost:9200/skus/_aliases?pretty|grep 1087 -A 3
"category_1087" : {
"filter" : {
"term" : {
"category_id" : 1087
}
},
"index_routing" : "category_1087",
"search_routing" : "category_1087"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment