Skip to content

Instantly share code, notes, and snippets.

@treff7es
Created May 21, 2012 21:30
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 treff7es/2764851 to your computer and use it in GitHub Desktop.
Save treff7es/2764851 to your computer and use it in GitHub Desktop.
Facet search with _script property which is more than 2 level depth
curl -XGET http://localhost:9200/twitter/tweet/_search -d '{"query":{"query_string":{"query":"*"}},"facets":{"termStatFacet":{"terms":{"size":500,"script":"_source.prop.prop1"}}}}'
{"took":183,"timed_out":false,"_shards":{"total":5,"successful":3,"failed":2,"failures":[{"index":"twitter","shard":2,"status":500,"reason":"QueryPhaseExecutionException[[twitter][2]: query[ConstantScore(NotDeleted(cache(_type:tweet)))],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: PropertyAccessException[[Error: could not access: prop; in class: org.elasticsearch.search.lookup.SourceLookup]\n[Near : {... _source.prop.prop1 ....}]\n ^\n[Line: 1, Column: 1]]; "},{"index":"twitter","shard":3,"status":500,"reason":"RemoteTransportException[[Thor][inet[/10.0.1.5:9301]][search/phase/query]]; nested: QueryPhaseExecutionException[[twitter][3]: query[ConstantScore(NotDeleted(cache(_type:tweet)))],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: PropertyAccessException[[Error: could not access: prop; in class: org.elasticsearch.search.lookup.SourceLookup]\n[Near : {... _source.prop.prop1 ....}]\n ^\n[Line: 1, Column: 1]]; "}]},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"twitter","_type":"tweet","_id":"3","_score":1.0, "_source" : {
"user": "kimchy",
"post_date": "2009-11-15T13:12:00",
"message": "Trying out elasticsearch, so far so good?",
"testProperty": "test",
"prop": {
"prop1": "test2"
}
}}]},"facets":{"termStatFacet":{"_type":"terms","missing":0,"total":1,"other":0,"terms":[{"term":"test2","count":1}]}}}
curl -XGET http://localhost:9200/twitter/tweet/_search -d '{"query":{"query_string":{"query":"*"}},"facets":{"termStatFacet":{"terms":{"size":500,"script":"_source.prop.prop1"}}}}'
curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{
"user": "kimchy",
"post_date": "2009-11-15T13:12:00",
"message": "Trying out elasticsearch, so far so good?"
}'
curl -XPUT http://localhost:9200/twitter/tweet/3 -d '{
"user": "kimchy",
"post_date": "2009-11-15T13:12:00",
"message": "Trying out elasticsearch, so far so good?",
"testProperty": "test",
"prop": {
"prop1": "test2"
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment