Reputation: 1
I have a simple ElasticSearch question. Let me explain through an example:
If I have two ES documents, both with a field drinks
, in which we store names of ordered drinks, how can I count the total number of each drink across both documents (drinks can repeat, since more than one person can order, say, Pepsi)?
So, if I have this:
document_1: drinks
: Pepsi, Pepsi, Pepsi, Fanta, water
document_2: drinks
: Pepsi, Pepsi, Fanta
I want to build a bar graph that will plot total number for each of these three drinks across both documents:
Pepsi: 5, Fanta: 2, water: 1
What would be the simplest way to do this? Thanks :-)
p.s. All I was able to achieve was to show number of documents in which each drink occurs, so I will get back Pepsi: 2, Fanta: 2, water: 1
, but I'm unable to count them all.
Upvotes: 0
Views: 19