Calculating terms_stats for entire key_feild?


(Rio) #1

Hi,

I was wondering if there was a way to calculating terms_stats for entire
key_field, not the terms within it.

For a simplified example, let's say I had these Article records:

[
{author: "Red Wolf", title: "Bread Roll", readers: 10}
{author: "Blue Wolf", title: "Bread Stick", readers: 10}
{author: "Red Wolf", title: "Sheep Skin", readers: 10}
{author: "Green Wolf", title: "Sheep Wool", readers: 10}
{author: "Bear", title: "Sheep Bread", readers: 10}
]

I'd like to calculate the stats for "Red Wolf", but with the following, I'd
get the terms like: ['red', 'wolf', 'blue', 'green', 'bear']

{
"query" : {
"match_all" : { }
},
"facets" : {
"author_reader_stats" : {
"terms_stats" : {
"key_field" : "author",
"value_field" : "readers"
}
}
}
}

I tried a variety of analyzers and some custom analyzers on the author
field, including not_analyzed, without luck.

Anyone have any suggestions?

Thanks sooo much!

-Rio

--


(system) #2