0

This is my result source.

{ "_source": { "Name": "Madagascar", "Genre": [ "Fiction" ], "AgeGroup": "11-13", "description": "Storks leave behind .", "duration": 3, "is_series":false}

I need to apply is_series = False & Genre=['Fiction']. I tried this query, but it is not working. Please help.

{"query":{"bool":{"filter":{"terms":{"Genre":["Action"],"is_series":False}}}}}

Hari Krishnan
  • 2,049
  • 2
  • 18
  • 29
Parvathy
  • 177
  • 1
  • 3
  • 10

1 Answers1

0

This is the query you're looking for:

{
  "query": {
    "bool": {
      "filter": [
        {
          "match": {
            "Genre": "Action"
          }
        },
        {
          "term": {
            "is_series": false
          }
        }
      ]
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360
  • But this {"query": {"bool": {"filter": [{"terms": {"Genre": ["Action"]}}]}}} returns Zero hits. {'took': 2, 'timed_out': False, '_shards': {'total': 5, 'successful': 5, 'skipped': 0, 'failed': 0}, 'hits': {'total': 0, 'max_score': None, 'hits': []}} – Parvathy Sep 06 '18 at 05:23
  • I've updated my query, you're better off using `match` instead of `terms` – Val Sep 06 '18 at 05:25
  • @Val , what you suggested `match` instead of `terms` ? – Amit Sep 06 '18 at 06:11
  • @AmitKhandelwal here is the answer https://stackoverflow.com/questions/40124317/what-is-the-difference-between-a-term-query-and-a-match-one/40124408#40124408 – Val Sep 06 '18 at 06:13
  • @Val ,I knew the difference b/w `match` and `terms`, I just missed that here `Action` was passed in query while, it would be indexed as `action`. Hence `match` is a better choice. I think it would be good to add this in the answer. – Amit Sep 06 '18 at 07:10