Hi,
I am not sure if this is a bug or it just works like this. Lets take an
example:
curl -XPUT 'http://localhost:9200/test1'
curl -XPUT 'http://localhost:9200/test1/type1/1' -d '{"obj1" : [{"name" :
"blue","count" : 4},{"name" : "green","count" : 6}]}'
curl -XPOST 'http://localhost:9200/test1/type1/_search?pretty=1' -d
'{"query": {"match_all": {}},"facets": {"facet1": {"terms_stats":
{"key_field" : "obj1.name","value_field": "obj1.count"}}}}'
This returns:
{
"took":1,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":1,
"max_score":1.0,
"hits":[
{
"_index":"test1",
"_type":"type1",
"_id":"1",
"_score":1.0,
"_source":{
"obj1":[
{
"name":"blue",
"count":4
},
{
"name":"green",
"count":6
}
]
}
}
]
},
"facets":{
"facet1":{
"_type":"terms_stats",
"missing":0,
"terms":[
{
"term":"green",
"count":1,
"total_count":2,
"min":4.0,
"max":6.0,
"total":10.0,
"mean":5.0
},
{
"term":"blue",
"count":1,
"total_count":2,
"min":4.0,
"max":6.0,
"total":10.0,
"mean":5.0
}
]
}
}
}
I have a question about this
{
"term":"green",
"count":1,
"total_count":2,
"min":4.0,
"max":6.0,
"total":10.0,
"mean":5.0
},
{
"term":"blue",
"count":1,
"total_count":2,
"min":4.0,
"max":6.0,
"total":10.0,
"mean":5.0
}
Why total_count, min, max, total and mean are calculated for whole document
obj1 and not just for specified terms (green, blue) separately ?
When obj1 has nested type and the request is:
curl -XPOST 'http://localhost:9200/test/type1/_search?pretty=1' -d
'{"query": {"match_all": {}},"facets": {"facet1": {"terms_stats":
{"key_field" : "name","value_field": "count"}},"nested":"obj1"}}'
the answer is OK:
{
"took":0,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":1,
"max_score":1.0,
"hits":[
{
"_index":"test",
"_type":"type1",
"_id":"1",
"_score":1.0,
"_source":{
"obj1":[
{
"name":"blue",
"count":4
},
{
"name":"green",
"count":6
}
]
}
}
]
},
"facets":{
"facet1":{
"_type":"terms_stats",
"missing":0,
"terms":[
{
"term":"green",
"count":1,
"total_count":1,
"min":6.0,
"max":6.0,
"total":6.0,
"mean":6.0
},
{
"term":"blue",
"count":1,
"total_count":1,
"min":4.0,
"max":4.0,
"total":4.0,
"mean":4.0
}
]
}
}
}
But the question is why in the first case is like above. Is it a bug or a
feature ?
Thanks.
Best regards.
Marcin.