title: Elasticsearch query with lookup table
body: <p>I am creating ES database for analyzing the historical data. I have 2 types of the data. First the product:</p>
  
  <pre><code>{
   "id" : 3,
   "name" : "Great product name",
   "feature1" : "Custom feature",
   "feature2" : true,
   "idCategory" : 2
  }
  </code></pre>
  
  <p>and a lot of historical data:</p>
  
  <pre><code>{
   "date" : "Apr 24, 2019 @ 23:59:59.000",
   "price" : 20.59
   "idStore" : 5
  }
  </code></pre>
  
  <p>I query records to get, for example, in one date range for products in specific category, get per day top X stores and their count of historical data.</p>
  
  <p>Firstly I combined this in one document and put in one index. It works great but the problem appears, when I want to change the category of a product, I have to update all the historical data. </p>
  
  <p>Is there a way to join the tables and query both documents at once. 
  I took a look about joins in ES: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/joining-queries.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/current/joining-queries.html</a> but I think there is not a nice, proper way to do this. </p>
  
  <p>Do you have any suggestions?</p>
  
  <p>Thank you.</p>