I have a question about Aggregations. I have documents with several fields:

{
field1 : A,
field2: B,
field3: C,
size: 1,
}

{
field1 : A,
field2: B2,
field3: C2,
size: 2,
}

{
field1 : Z,
field2: B3,
field3: C3,
size: 99,
}

And I need to be able to calculate aggregations for each one of those
fields, and get the sum of the sizes for each field, so for example,
aggregating by field1 should get me { A, size = 3 }, {Z, size = 99}.

Looking at the documentation for aggregations I can see how to get the sum
for a field and how to get the terms and their counts, but I need a
combination of both, what is the best way to do this?

I have a question about Aggregations. I have documents with several fields:

{
field1 : A,
field2: B,
field3: C,
size: 1,
}

{
field1 : A,
field2: B2,
field3: C2,
size: 2,
}

{
field1 : Z,
field2: B3,
field3: C3,
size: 99,
}

And I need to be able to calculate aggregations for each one of those
fields, and get the sum of the sizes for each field, so for example,
aggregating by field1 should get me { A, size = 3 }, {Z, size = 99}.

Looking at the documentation for aggregations I can see how to get the sum
for a field and how to get the terms and their counts, but I need a
combination of both, what is the best way to do this?

If I search in my index and those three documents match my query I want a
list of the possible values that 'field1' can take and the sum of the
'size' fields for all documents with each value in my result set. So in
this case I would expect:

On Fri, May 2, 2014 at 11:44 AM, Jose A. Garcia <argan...@gmail.com<javascript:>

wrote:

Hi,

I have a question about Aggregations. I have documents with several
fields:

{
field1 : A,
field2: B,
field3: C,
size: 1,
}

{
field1 : A,
field2: B2,
field3: C2,
size: 2,
}

{
field1 : Z,
field2: B3,
field3: C3,
size: 99,
}

And I need to be able to calculate aggregations for each one of those
fields, and get the sum of the sizes for each field, so for example,
aggregating by field1 should get me { A, size = 3 }, {Z, size = 99}.

Looking at the documentation for aggregations I can see how to get the
sum for a field and how to get the terms and their counts, but I need a
combination of both, what is the best way to do this?

If I search in my index and those three documents match my query I want a
list of the possible values that 'field1' can take and the sum of the
'size' fields for all documents with each value in my result set. So in
this case I would expect:

On Fri, May 2, 2014 at 11:44 AM, Jose A. Garcia argan...@gmail.comwrote:

Hi,

I have a question about Aggregations. I have documents with several
fields:

{
field1 : A,
field2: B,
field3: C,
size: 1,
}

{
field1 : A,
field2: B2,
field3: C2,
size: 2,
}

{
field1 : Z,
field2: B3,
field3: C3,
size: 99,
}

And I need to be able to calculate aggregations for each one of those
fields, and get the sum of the sizes for each field, so for example,
aggregating by field1 should get me { A, size = 3 }, {Z, size = 99}.

Looking at the documentation for aggregations I can see how to get the
sum for a field and how to get the terms and their counts, but I need a
combination of both, what is the best way to do this?

Thanks in advance,
Jose.

--
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 elasticsearc...@googlegroups.com.

That's closer but I would get all the possible values and counts for
'fieldA' and the total sum of 'size' for my result set, but I need the sum
of sizes for each value of 'fieldA', so it's a combination of both terms
and sum, but none seems to give me exactly what I need...

Thanks,
Jose.

On Friday, 2 May 2014 15:18:37 UTC+1, Adrien Grand wrote:

Oh, I'm sorry, I completely missed your question, I thought you wanted to
merge the counts for different fields.

Would this aggregation do what you are looking for?
{
"terms": {
"field": "fieldA"
},
"aggs": {
"size_sum": {
"sum": {
"field": "size"
}
}
}
}

If I search in my index and those three documents match my query I want a
list of the possible values that 'field1' can take and the sum of the
'size' fields for all documents with each value in my result set. So in
this case I would expect:

On Fri, May 2, 2014 at 11:44 AM, Jose A. Garcia argan...@gmail.comwrote:

Hi,

I have a question about Aggregations. I have documents with several
fields:

{
field1 : A,
field2: B,
field3: C,
size: 1,
}

{
field1 : A,
field2: B2,
field3: C2,
size: 2,
}

{
field1 : Z,
field2: B3,
field3: C3,
size: 99,
}

And I need to be able to calculate aggregations for each one of those
fields, and get the sum of the sizes for each field, so for example,
aggregating by field1 should get me { A, size = 3 }, {Z, size = 99}.

Looking at the documentation for aggregations I can see how to get the
sum for a field and how to get the terms and their counts, but I need a
combination of both, what is the best way to do this?

Thanks in advance,
Jose.

--
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 elasticsearc...@googlegroups.com.

That's closer but I would get all the possible values and counts for
'fieldA' and the total sum of 'size' for my result set, but I need the sum
of sizes for each value of 'fieldA', so it's a combination of both terms
and sum, but none seems to give me exactly what I need...

This should work: The sum aggregation is under the terms aggregation, so
sums would be computed for each unique value of 'fieldA'.

It's just ignoring all the values of 'file1' and adding all the sizes from
the response. Am I doing something wrong?

Thanks,
Jose.

On Friday, 2 May 2014 15:55:50 UTC+1, Adrien Grand wrote:

On Fri, May 2, 2014 at 4:47 PM, Jose A. Garcia <argan...@gmail.com<javascript:>

wrote:

That's closer but I would get all the possible values and counts for
'fieldA' and the total sum of 'size' for my result set, but I need the sum
of sizes for each value of 'fieldA', so it's a combination of both terms
and sum, but none seems to give me exactly what I need...

This should work: The sum aggregation is under the terms aggregation, so
sums would be computed for each unique value of 'fieldA'.

Your aggregation has no name, and unfortunately this causes undefined
behavior because the parsing is too lenient in 1.1 and previous versions
(will be fixed in 1.2.0). Please try the following request:

That's closer but I would get all the possible values and counts for
'fieldA' and the total sum of 'size' for my result set, but I need the sum
of sizes for each value of 'fieldA', so it's a combination of both terms
and sum, but none seems to give me exactly what I need...

This should work: The sum aggregation is under the terms aggregation,
so sums would be computed for each unique value of 'fieldA'.

On Friday, 2 May 2014 16:28:08 UTC+1, Adrien Grand wrote:

Your aggregation has no name, and unfortunately this causes undefined
behavior because the parsing is too lenient in 1.1 and previous versions
(will be fixed in 1.2.0). Please try the following request:

That's closer but I would get all the possible values and counts for
'fieldA' and the total sum of 'size' for my result set, but I need the sum
of sizes for each value of 'fieldA', so it's a combination of both terms
and sum, but none seems to give me exactly what I need...

This should work: The sum aggregation is under the terms aggregation,
so sums would be computed for each unique value of 'fieldA'.

Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.