Terms stats facet using script on multiple fields

I often use terms facet script to do grouping on multiple fields, as
following:

{
"facets": {
"my_terms_facet": {
"terms": {
"size": 5,
"script": "doc['field1'].value + "~" +
doc['field2'].value + "
~" + doc['field3'].value"
}
}
}
}

The result is parsed on the response using client side scripts for
necessary display formatting.

The above query gives only the count, whereas now I am looking for summing
up based on a fourth field.

Is something possible on combining script and terms-stats facet? Something
like following?

{
"facets": {
"my_terms_stats_facet": {
"terms_stats": {
"size": 5,
"key_script": "doc['field1'].value + "~" +
doc['field2'].value + "
~" + doc['field3'].value",
"value_field": "field4"
}
}
}
}

Thanks in advance,

  • Sujoy.

--

Hi,

Any hint/hope on the following?

Thanks,

  • Sujoy.

On Tuesday, September 25, 2012 11:53:12 AM UTC+5:30, Sujoy Sett wrote:

I often use terms facet script to do grouping on multiple fields, as
following:

{
"facets": {
"my_terms_facet": {
"terms": {
"size": 5,
"script": "doc['field1'].value + "~" +
doc['field2'].value + "
~" + doc['field3'].value"
}
}
}
}

The result is parsed on the response using client side scripts for
necessary display formatting.

The above query gives only the count, whereas now I am looking for summing
up based on a fourth field.

Is something possible on combining script and terms-stats facet? Something
like following?

{
"facets": {
"my_terms_stats_facet": {
"terms_stats": {
"size": 5,
"key_script": "doc['field1'].value + "~" +
doc['field2'].value + "
~" + doc['field3'].value",
"value_field": "field4"
}
}
}
}

Thanks in advance,

  • Sujoy.

--