Skip to content

Instantly share code, notes, and snippets.

@radu-gheorghe
Created November 15, 2012 07:56
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 radu-gheorghe/4077293 to your computer and use it in GitHub Desktop.
Save radu-gheorghe/4077293 to your computer and use it in GitHub Desktop.
Elasticsearch terms facet string
$ curl -XPOST localhost:9200/test/test/ -d '{"timestamp": "random_date", "tag":"blue", "counter": "5"}'
{"ok":true,"_index":"test","_type":"test","_id":"qVmyc9otSqWqUOKWoteM5Q","_version":1}
$ curl -XGET localhost:9200/test/test/_mapping?pretty=true
{
"test" : {
"properties" : {
"counter" : {
"type" : "string"
},
"tag" : {
"type" : "string"
},
"timestamp" : {
"type" : "string"
}
}
}
}
$ curl -XPOST localhost:9200/test/test/_search?pretty=true -d '{
> "query": {
> "match_all": {}
> },
> "facets" : {
> "test_facet" : {
> "terms_stats" : {
> "key_field" : "tag",
> "value_field" : "counter"
> }
> }
> }
> }'
{
"error" : "SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[tbpy27tVRIeA5qjVsI-a4Q][test][0]: QueryPhaseExecutionException[[test][0]: query[ConstantScore(NotDeleted(cache(_type:test)))],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.NumericFieldData]; }]",
"status" : 500
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment