Multiple Filters Query

I indexed some movie data. Each movie has a Genre field that sometimes contains an array of keywords (ex: "Comedy", "Action", "Romance").

When I do a query:
GET movies/_search
{
"query" : {
"bool" : {
"must" : {"match" : {"Genre" : "Comedy"}}
}
}
}

The above query returns only movies that have only Comedy as its Genre, if the document's Genre is "Comedy", "Action", I don't see it. How do I do a search so that I can see all movies that have "Comedy" as one of its Genres.

Thanks!

I can't reproduce your problem with this:

DELETE test
PUT test/_doc/1
{
  "genre": [ "Comedy", "Action", "Romance"]
}
PUT test/_doc/2
{
  "genre": [ "Comedy" ]
}
GET test/_search
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "genre": "Comedy"
        }
      }
    }
  }
}

It gives:

{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 0.2876821,
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 0.2876821,
        "_source" : {
          "genre" : [
            "Comedy"
          ]
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 0.2876821,
        "_source" : {
          "genre" : [
            "Comedy",
            "Action",
            "Romance"
          ]
        }
      }
    ]
  }
}

I posted json into the index incorrectly, sorry about that. You are right, thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.