"Grouping"


(Josef Rousek) #1

Hello,
I'm not sure how to solve following problem.
I have following data and I need to separate negative and positive valuesand then group them by tags.
I used terms_stats facet to get the *total *field, but I'm lost in
possibilities how to get income and expense fields.

{
"id": 10337,
"items": [
{
"id": 1,
"tags": [
"tag1"
],
"value": 305,
},
{
"id": 2,
"tags": [
"tag1"
],
"value": -64
}
]
}

Expected result is something like this:

{
"tag1":
{
"income": 305,
"expense": -64,
"total": 241
}
}

Thank you

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Ivan Brusic) #2

You are probably thinking of field collapsing, which will hopefully be
available in some form in elasticsearch 1.0.

--
Ivan

On Tue, Nov 19, 2013 at 9:44 AM, Josef Rousek josef.rousek@gmail.comwrote:

Hello,
I'm not sure how to solve following problem.
I have following data and I need to separate negative and positive
values and then group them by tags.
I used terms_stats facet to get the *total *field, but I'm lost in
possibilities how to get income and expense fields.

{
"id": 10337,
"items": [
{
"id": 1,
"tags": [
"tag1"
],
"value": 305,
},
{
"id": 2,
"tags": [
"tag1"
],
"value": -64
}
]
}

Expected result is something like this:

{
"tag1":
{
"income": 305,
"expense": -64,
"total": 241
}
}

Thank you

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3