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?
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?
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?
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?
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?
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.