Count total number of words from all documents from a specific field accordingly

Hello and good day!

Someone asked this question but no one seems answered or tried to suggest techniques: Count the Number of words in the field Elastic search 6.2

Now, I'm trying to produce a report from Elasticsearch to count the number of WORDS / TOKENS from a specific field called content

Is there a proper aggregation for this?

For example, I have this query:

GET web/_search
{
  "query":{
     "bool":{
        "must":[
           {
              "query_string":{
                 "fields":[
                    "title",
                    "content"
                 ],
                 "query":"((\"Mayor Isko\") AND (\"Isko Moreno\") AND (\"Manila\" OR \"Divisoria\")) OR ((\"Mayor Isko Moreno\" OR \"Mayor Vico Sotto\") AND (\"Manila\" OR \"Pasig\"))"
              }
           },
           {
              "range":{
                 "pub_date":{
                    "from":1569456000,
                    "to":1570060800
                 }
              }
           }
        ]
     }
  }
}

And for example, this query produced 23 DOCUMENTS, I want to make a response telling me how MANY words does those 23 documents contain?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.