Re: Group by field and then sum the groups

2014-08-06 Thread Cameron Barker
This worked perfectly!  Thank you for your help.

On Wednesday, August 6, 2014 3:49:57 AM UTC-4, Tihomir Lichev wrote:
>
> Thanks! You're absolutely right. Copy/paste error :)
>
> {
>  "aggs": {
>"user_likes": {
>  "terms": {
>"field": "user_id"
>  }, 
>  "aggs": {
>"likes_sum": {
>  "sum": {
>"field": "likes"
>  }
>}
>  }
>}
>  }
> }
>
> 06 август 2014, сряда, 10:06:38 UTC+3, Jun Ohtani написа:
>>
>> Hi,
>>
>> I think second "aggs" use "sum" instead of "terms", in "likes_sum".
>>
>>
>> 2014-08-06 14:32 GMT+09:00 Tihomir Lichev :
>>
>>> You can use aggregations:
>>> {
>>>  "aggs": {
>>>    "user_likes": {
>>>  "terms": {
>>>"field": "user_id"
>>>  }, 
>>>  "aggs": {
>>>"likes_sum": {
>>>  "terms": {
>>>"field": "likes"
>>>  }
>>>}
>>>  }
>>>}
>>>  }
>>> }
>>>
>>>
>>> 05 август 2014, вторник, 23:11:59 UTC+3, Cameron Barker написа:
>>>
>>>> Hi all,
>>>>
>>>> I have an elastic database of posts, each post has a *user_id* and has 
>>>> *likes* field.  My goal is to output for a query how many likes in 
>>>> total each user has.
>>>>
>>>> I wondered if any one had any advice/direction I could take to achieve 
>>>> this?
>>>>
>>>> input:
>>>> {user_id: 10, likes: 20}
>>>> {user_id: 9, likes: 10}
>>>> {user_id: 10, likes: 25}
>>>> {user_id: 9, likes: 15}
>>>>
>>>> output:
>>>> User: 10 likes: 45
>>>> User: 9 likes: 25
>>>>
>>>>  -- 
>>> 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.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/elasticsearch/7bec5f9a-16cf-4723-87a6-7e95de45d0ea%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/elasticsearch/7bec5f9a-16cf-4723-87a6-7e95de45d0ea%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> ---
>> Jun Ohtani
>> blog : http://blog.johtani.info
>>  
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/fb530eeb-0a9f-4460-905a-92f0d74fa5ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Group by field and then sum the groups

2014-08-05 Thread Cameron Barker
Hi all,

I have an elastic database of posts, each post has a *user_id* and has 
*likes* field.  My goal is to output for a query how many likes in total 
each user has.

I wondered if any one had any advice/direction I could take to achieve this?

input:
{user_id: 10, likes: 20}
{user_id: 9, likes: 10}
{user_id: 10, likes: 25}
{user_id: 9, likes: 15}

output:
User: 10 likes: 45
User: 9 likes: 25

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/d016c5d0-ad03-488e-9c7b-73cf85999e10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unique data by referencing 2 fields

2014-07-30 Thread Cameron Barker
Hi all,

Would it be possible to get unique items from an elastic search database 
that reference 2 fields for uniqueness, all while using only elastic search 
or a plug in?

*I.E.*
*Initial Data:*
{
 provider: "tumblr"
 text: "I need to get this."
}
{
 provider: "twitter"
 text: "I need to get this."
}
{
 provider: "tumblr"
 text: "I need to get this."
}

*Return:*
{
 provider: "twitter"
 text: "I need to get this."
}
{
 provider: "tumblr"
 text: "I need to get this."
}

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/e67f33df-643e-4840-a056-271b5db217ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.