Need help in adding And conditions using must query

Hi Team,

I am trying to query a data where i need to add filters based on fields but it returns multiple results instead of a single record.

here is the request
{
"query": {
"bool": {
"must": [
{"match": {"categories_filter": "hollywood"}},
{"match": {"sub_categories_filter": "Sub-Category 7"} }

  ]
}

}
}

and here is the response

{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 3.0786304,
"hits": [
{
"_index": "pvrmod",
"_type": "movie",
"_id": "43",
"_score": 3.0786304,
"_source": {
"id": 43,
"cast": "Ben Stiller, John Turturro, Olivier Martinez",
"synopsis": "",
"joinNowUrl": "",
"createdBy": "",
"ticketPrice": "",
"screeningFlag": "",
"screeningDetails": "",
"address": "",
"showTime": "",
"ticketTypeSelect": "",
"censor_rating": "V/UA",
"code": "HLR06",
"type": "Non-3D",
"trailer": "https://www.youtube.com/watch?v=cwdliqOGTLw",
"imdb_code": "1234654",
"tags": [
"Animation"
],
"genre": "Adventure",
"languages": "Bengali",
"actors": [
{
"actor": "Ben Stiller"
},
{
"actor": "John Turturro"
},
{
"actor": "Olivier Martinez"
}
],
"categories": [
{
"category": "Category2"
},
{
"category": "Hollywood"
}
],
"categories_filter": [
"Category2,Hollywood"
],
"sub_categories_filter": [
"Sub-Category1,Sub-Category 4,Sub-Category 5,Sub-Category 6,Sub-Category 7"
],
"countries": [
{
"country": "India",
"region": "South",
"state": "Tamil Nadu",
"city": "Chennai"
}
]
}
},
{
"_index": "pvrmod",
"_type": "movie",
"_id": "38",
"_score": 2.6205246,
"_source": {
"id": 38,
"cast": "",
"synopsis": ".",
"joinNowUrl": "",
"createdBy": "",
"ticketPrice": "",
"screeningFlag": "",
"screeningDetails": "",
"address": "",
"showTime": "",
"ticketTypeSelect": "",
"censor_rating": "V/UA",
"code": "HLR02",
"type": "Non-3D",
"trailer": "https://www.youtube.com/watch?v=nTkcX989XP0",
"imdb_code": "812352",
"tags": [],
"genre": "",
"languages": "",
"actors": [],
"categories": [
{
"category": "Hollywood"
}
],
"categories_filter": [
"Hollywood"
],
"sub_categories_filter": [
"Sub-Category 4"
],
"countries": []
}
}
]
}
}

Is it possible that sub_categories_filter is an analyzed field? In that case, "match": {"sub_categories_filter": "Sub-Category 7"} means "match Sub or Category or 7".

Hi Ywelsch,

Thanks for the reply.

I need to add conditions eg

select * from movies where categories_filter='hollywood' AND sub_categories_fileter='sub-category7' AND genre='Drama' and so on...

let me know if there is any issue with implementation.

What happens if you replace "match" by "match_phrase"?

Can you show me the mapping? https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html

Hi Ywelsh,

Thanks for the reply it worked.

here is the mapping url

http://e349b6492cb87eee13b05b0c87ff330d.us-east-1.aws.found.io:9200/pvrmod/_mappings

right now i am facing issue with data with fields having multiple value in strings. is there any option to filter those out ?

eg languages : english, hindi, french