0
votes

Facing issue while query with multi index queries. I have multiple indices with different attributes. I want a query which return result from all indices and filter result only if one attribute present.

Currently If attribute is not present it does not return the response for that index.

Example:

FirstIndex {
    attribute: {
         type: type1
         flag: false
    }
}

SecondIndex{
    attribute: {
         type: type1
   }
}

above flag the attribute:flag is not there so if search is on flag=false it should return both matching as well as secondIndex. Something like outer join in dbms.

1

1 Answers

0
votes

probably you can give a try with the following query:

{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "should": [
            {
              "exists": {
                "field": "user"
              }
            },
            {
              "missing": {
                "field": "user"
              }
            }
          ]
        }
      }
    }
  }
}

In the field column add the fields required.