title: Count by keyword in several indexes in ElasticSearch 6
body: <p>I'm relatively new to ElasticSearch so I may be asking something silly. Anyway, here's my use case:</p>
  
  <p>We want to store all the messaging going on in our Booking Engine, and as a plus, see if we can get some nice data out of it.</p>
  
  <p>Basically we would store 5 different documents in as many indexes:</p>
  
  <ul>
  <li><code>SessionOpen Response</code>, with a <code>sessionId</code> and all the navigation data (<code>DNS</code>, <code>country</code>, <code>ip</code>, etc.).</li>
  <li><code>Availability Request/ Response</code>, with the same <code>sessionId</code> as
  keyword. </li>
  <li><code>Booking Request/ Response</code>, with the same <code>sessionId</code> as
  keyword.</li>
  </ul>
  
  <p>My question is, would it be possible to filter the <code>sessionId</code>'s by its navigation data (for example, <code>country</code>), and then count the number of <code>Availability Requests</code> / <code>Booking</code> for these filtered sessionId's?</p>
  
  <p>The idea is to get something like this:</p>
  
  <pre><code>╔═════════╦════════════════╦══════════╗
  ║ Country ║ Requests       ║ Bookings ║
  ╠═════════╬════════════════╬══════════╣
  ║ Spain   ║            300 ║        5 ║
  ║ Germany ║            650 ║        9 ║
  ║ France  ║            250 ║        3 ║
  ╚═════════╩════════════════╩══════════╝
  </code></pre>
  
  <p>I've looked into it <a href="https://stackoverflow.com/questions/22611049/join-query-in-elasticsearch#22633775">quite a bit</a> and it <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/joining-queries.html" rel="nofollow noreferrer">seems impossible</a> to search in several indexes at once, but maybe I'm just storing the data in the wrong way. I could (for example), store all the navigation data in every document and then query those, but it seems like it could be wasting space and be heavy on indexation as well. </p>
  
  <p>Since ElasticSearch <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html" rel="nofollow noreferrer">removed mapping types</a> and encourages one document per index, I don't see how to get this kind of data easily. </p>