title: Is it possible to filter records of one index from another index in elasticsearch query?
body: <p>Lets say I have 100 records in index1 and 10 records in index2. And I want to get like this:</p>
  
  <pre><code>select * from index1 where id not in (select id from index2)
  </code></pre>
  
  <p>Can we have the same above query in elasticsearch or is it even possible. </p>
  
  <p>I have tried multiple index search and it is working, however I have no clue for filter part. I am using elasticsearch-7.3.0</p>
  
  <p>Please suggest!</p>
  
  <p>Below query I have tried:</p>
  
  <pre><code>GET index1/_search
  {
    "query": {
      "bool": {
        "must_not": [
          {
            "terms": {
          "id.keyword": {
              "index" : "index2",
              "id" : "_all",
              "path" : "id"
          }
      }
          }
        ]
      } 
  
    }
  }
  </code></pre>