Given doc: books
[
{
name: "book a",
authors:
[
{
name: "John",
}
{
name: "Paul"
}
]
},
{
name: "book b",
authors:
[
{
name: "Paul"
}
]
}
]
Goal: Return the book which match name
= book a
AND match one of the author name with authors.name
= John
.
What I tried:
"must": [
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"name": {
"value": "book a"
}
}
},
{
"bool": {
"should": [
{
"term": {
"authors.name": {
"value": "John"
}
}
}
]
}
}
]
}
}
]
}
}
]
mapping name: text authors: dynamic