How do I create a boolean "OR" filter?

Yup sorry I read wrong, just saw you did not want scoring...

Took me a few minutes how about this...
Wrap the bool should inside the filter...

GET discuss-test/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "should": [
              {
                "term": {
                  "type": "canis"
                }
              },
              {
                "term": {
                  "name": "mary"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Result is


{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 0.0,
    "hits" : [
      {
        "_index" : "discuss-test",
        "_type" : "_doc",
        "_id" : "UatJdXsBm1AJFmUV716l",
        "_score" : 0.0,
        "_source" : {
          "type" : "feline",
          "gender" : "female",
          "name" : "mary"
        }
      },
      {
        "_index" : "discuss-test",
        "_type" : "_doc",
        "_id" : "UqtJdXsBm1AJFmUV7162",
        "_score" : 0.0,
        "_source" : {
          "type" : "canis",
          "gender" : "male",
          "name" : "spot"
        }
      },
      {
        "_index" : "discuss-test",
        "_type" : "_doc",
        "_id" : "U6tJdXsBm1AJFmUV717P",
        "_score" : 0.0,
        "_source" : {
          "type" : "canis",
          "gender" : "female",
          "name" : "mary"
        }
      }
    ]
  }
}
1 Like