So I am trying to search across nested objects in ElasticSearch and I am not doing something correctly as I get no results.
I run the following commands:-
Create Index and Mappings
PUT /demo
{
"mappings": {
"person": {
"properties": {
"children": {
"type": "nested",
"properties": {
"fullName": {
"type": "string"
},
"gender": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
Add person document
POST /demo/person/1
{
"children": [{
"fullName" : "Bob Smith",
"gender": "M"
}]
}
These all execute as expected. However, when I come to search on them as outlined in the documentation I do not get any results.
Query
POST /demo/person/_search
{
"query": {
"bool": {
"must": [{
"match_all": {}
},
{
"nested": {
"path": "children",
"query": {
"bool": {
"must": [{
"match": {
"fullName": "Bob Smith"
}
}]
}
}
}
}]
}
}
}
What am I doing incorrectly?