title: How to get total word occurences in elastic search?
body: <p>Is there a way to get the total count of occurrences of the searched string instead of result hit count?</p>
  <p>My data structure is a bit complex with nested docs but I have added a simple version of my data below. if anyone is able to help find the count on this, I can convert it to my version of code.</p>
  <p>Elastic search data is :</p>
  <pre><code>[
      {
        &quot;page&quot;: 1,
        &quot;text&quot;: &quot;Sample PDF Document.\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.&quot;
      },
      {
        &quot;page&quot;: 2,
        &quot;text&quot;: &quot;sample PDF sample Document test content&quot;
      },
      {
        &quot;page&quot;: 3,
        &quot;text&quot;: &quot;Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\n sample content&quot;
      },
      {
        &quot;page&quot;: 4,
        &quot;text&quot;: &quot;PDF test sample Document lorem ipsum sample.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. Sample content.&quot;
      },
      {
        &quot;page&quot;: 5,
        &quot;text&quot;: &quot;PDF Document&quot;
      },
      {
        &quot;page&quot;: 6,
        &quot;text&quot;: &quot;sdsd&quot;
      },
      {
        &quot;page&quot;: 7,
        &quot;text&quot;: &quot;lorem ipsum&quot;
      }
    ]
  </code></pre>
  <p>I'm able to get filter aggregation but the text <code>sample PDF sample Document test content</code> will return the count as 1 but the word <code>sample</code> is twice in the same field.</p>