I want to get only nested fields, but cannot since it\'s not leaf fields.
GET index/_search
{
\"size\": 10,
\"fields\": [
\"nested_fields\"
If you don't have a certain query that should match the nested fields somehow, you can do it like this:
GET /index/_search
{
"size": 10,
"_source": ["nested_fields.id", "nested_fields.name"]
}
If you also have a nested
query and you want to return the nested docs that matched you can do it like this (with inner_hits
):
{
"query": {
"nested": {
"path": "nested_fields",
"query": {"match_all": {}},
"inner_hits": {}
}
}
}