I want Elasticsearch to return only the matched object if I index a document containing an array.
For Example:
PUT /testindex/books/1
{
"Book" : [
{
"id": 12,
"title" : "First book",
"author" : [
{
"firstname" : "Frank",
"surname": "Smith",
"id": 3
},
{
"firstname" : "Kate",
"surname" : "Walker",
"id" : 12
}
]
},
{
"id" : 13,
"title" : "Second book",
"author" : [
{
"firstname" : "Frank",
"surname": "Smith",
"id": 3
}
]
}
]
}
If I now search by firstname like that:
GET /testindex/books/_search
{
"_source": "Book.author",
"query": {
"bool": {
"must": [
{
"match": {
"Book.author.firstname": "Frank"
}
}
]
}
}
}
I would expect to only get the matching author objects returned. Instead, I get the whole document returned.