Elasticsearch terms_stats doubt

Hello,

I'm new with ES and I'm trying to retrieve aggreated data by term, I have
something like:

{"total": 10,"product": 1,"campaign": 1},
{"total": 10,"product": 1,"campaign": 2},
{"total": 10,"product": 1,"campaign": 1},
{"total": 10,"product": 2,"campaign": 1}

So, this is my facet:

"x": {
  "terms_stats": {
    "key_field": [
      "product",
      "campaign"
    ],
    "value_field": "total"
  }

This is the result:

[
{
term: 1
count: 3
total_count: 3
min: 10
max: 10
total: 30
mean: 10
}
{
term: 2
count: 1
total_count: 1
min: 10
max: 10
total: 10
mean: 10
}
]

This information is refered to campaigns, not both product and campaign
terms. My expectation was something like:

terms: [
{
term: [1,1]
count: 2
total_count: 2
min: 10
max: 10
total: 20
mean: 10
}
{
term: [1,2]
count: 1
total_count: 1
min: 10
max: 10
total: 10
mean: 10
}
{
term: [2,1]
count: 1
total_count: 1
min: 10
max: 10
total: 10
mean: 10
}
]

I don't know if ES has a way to do that.

Somebody has an idea?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/04860e26-47be-4062-9fcb-128095022a76%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Raul,

Unfortunately, the terms_stats facet does not support scripting the terms
key. You can try aggregations (ES 1.0) or if you want to use term_stats
facet, you will need to introduce an extra field that is a combination of
product and campaign to your JSON documents.

{"total": 10,"product": 1,"campaign": 1,"product_campaign": "11"},
{"total": 10,"product": 1,"campaign": 2,"product_campaign": "12"},
{"total": 10,"product": 1,"campaign": 1,"product_campaign": "11"},
{"total": 10,"product": 2,"campaign": 1,"product_campaign": "21"}

And then

"x": {
  "terms_stats": {
    "key_field": [
      "product_campaign"
    ],
    "value_field": "total"
  }

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9f6fde1c-c424-4a96-ae72-6142b52018b5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Binh,

The problem is that these aren't not the only one case which I want to
aggregating them that way is rather complicated.

So, there is a chance to do that in ES 1.0. I'm going to start its
installation.

Chers,
Raúl.

On Friday, February 7, 2014 2:41:22 PM UTC+1, Binh Ly wrote:

Raul,

Unfortunately, the terms_stats facet does not support scripting the terms
key. You can try aggregations (ES 1.0) or if you want to use term_stats
facet, you will need to introduce an extra field that is a combination of
product and campaign to your JSON documents.

{"total": 10,"product": 1,"campaign": 1,"product_campaign": "11"},
{"total": 10,"product": 1,"campaign": 2,"product_campaign": "12"},
{"total": 10,"product": 1,"campaign": 1,"product_campaign": "11"},
{"total": 10,"product": 2,"campaign": 1,"product_campaign": "21"}

And then

"x": {
  "terms_stats": {
    "key_field": [
      "product_campaign"
    ],
    "value_field": "total"
  }

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1a74ce8e-fc6f-4e2b-98ce-374c37c33f42%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.