Hi,
I want to search documents in an index which contains an array type with two documents :
PUT my_index/doc/1
{
"message": "some arrays in this document...",
"tags": [ "elasticsearch", "wow" ],
"lists": [
{
"name": "cool_list",
"description": "cool stuff list"
}
]
}
PUT my_index/doc/2
{
"message": "some arrays in this document...",
"tags": "elasticsearch",
"lists": [
{
"name": "cool_list",
"description": "just a cool list"
},
{
"name": "other_list",
"description": "uncool stuff list"
}
]
}
How do I get the documents in which the attribute "lists" contains an element which matches both of the following criterias :
- "name" matches "cool_list"
- "description" matches "stuff"
With the following search query, I am not getting the results that I want, because I also get doc 2 in which none of the two items match both the two criterias, but each item matches one of the two different criterias :
GET my_index/_search
{
"query": {
"bool": {
"must": [
{ "match": { "lists.name": "cool_list" } },
{ "match": { "lists.description": "stuff" } }
]
}
}
}