title: Get most searched terms from indexes that are referenced by an alias
body: <p>The search is pointing to an alias.
  The indexing process create a new index every 5 minutes.
  Then the alias is updated, pointing to the new index.
  The index is recreated to avoid sync problems that can occur if we update item by item when a change is made.</p>
  <p>However, I need to keep track of the searched terms to produce a dashboard to list the most searched terms in a period. Or even using Kibana to show/extract it.</p>
  <p>*The searched terms can be multi words, such as &quot;white&quot;, &quot;white summer night&quot;, etc. We are looking to rank the term, not the individual words.</p>
  <p>I don't have experience with Elasticsearch and the searches that I have tried did not bring relevant solutions.</p>
  <p>Thanks for the help!</p>
  <pre><code>{
      &quot;actions&quot; : [
          { &quot;remove&quot; : { &quot;index&quot; : &quot;catalog*&quot;,       &quot;alias&quot; : &quot;catalog-index&quot; } },
          { &quot;add&quot;    : { &quot;index&quot; : &quot;catalog1234566&quot;, &quot;alias&quot; : &quot;catalog-index&quot; } }
      ]
  }
  </code></pre>
  <p>Mappings:</p>
  <pre><code>{
     &quot;mappings&quot;:{
        &quot;properties&quot;:{
           &quot;created_at&quot;:{
              &quot;type&quot;:&quot;integer&quot;
           },
           &quot;search_terms_key&quot;:{
              &quot;type&quot;:&quot;keyword&quot;
           }
        }
     }
  }
  </code></pre>
  <p>Query:</p>
  <pre><code>{
     &quot;query&quot;:{
        &quot;match_all&quot;:{
           
        }
     },
     &quot;aggs&quot;:{
        &quot;search_terms_key&quot;:{
           &quot;terms&quot;:{
              &quot;field&quot;:&quot;search_terms_key&quot;,
              &quot;value_type&quot;:&quot;string&quot;
           }
        }
     }
  }
  </code></pre>