title: Difference of two query results in Elasticsearch
body: <p>Let's say we've indexes of e-commerce store data, and we want to get the difference of list of products which are present in 2 stores.</p>
  
  <p>Information on the index content: A sample data stored in each document looks like below:</p>
  
  <pre><code>{
     "product_name": "sample 1",
     "store_slug": "store 1",
     "sales_count": 42,
     "date": "2018-04-04"
  }
  </code></pre>
  
  <p>Below are queries which gets me all products present in 2 stores individually,</p>
  
  
  
  <pre><code>Data for store 1
  
  curl -XGET 'localhost:9200/store/_search?pretty' -H 'Content-Type: application/json' -d'
     {
         "_source": ["product_name"],
         "query": {
             "constant_score" : {
                 "filter" : {
                      "bool" : {
                         "must" : [
                             { "term" : { "store_slug" : "store_1"}}]}}}}}'
  
  Data for store 2
  
  curl -XGET 'localhost:9200/store/_search?pretty' -H 'Content-Type: application/json' -d'
     {
         "_source": ["product_name"],
         "query": {
             "constant_score" : {
                 "filter" : {
                      "bool" : {
                         "must" : [
                             { "term" : { "store_slug" : "store_2"}}]}}}}}'
  </code></pre>
  
  <p>Is it possible with elasticsearch query to get the difference of both result(without doing using some script/ other languages)?</p>
  
  <p>E.g. of above operation: Let's say "store 1" is selling products ["product 1", "product 2"] and "store 2" is selling products ["product 1", "product 3"], So expected output of difference of products of "store 1" and "store 2" is "product 2".</p>