I am able to get all of the values in the database for a text field using an aggregate query in elastic search 6.8:
{
aggs: {
values: {
terms: { field: 'City.keyword', size: 200 },
},
},
size: 0,
};
I am trying to do the same thing for nested field.
Below is an example of a text field (City) and a nested field (Cooling)
"City": "Fredericksburg",
"Cooling": [
{
"key": "Fuel",
"value": "Electric"
},
{
"key": "Central Air",
"value": "Y"
},
{
"key": "Central A/C",
"value": "true"
}
],
And here's the documentation I've been referencing: https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-aggregations-bucket-terms-aggregation.html
Here is the relevant mapping:
{
"listings:366": {
"mappings": {
"_default_": {
"_all": {
"enabled": false
},
"dynamic_templates": [
...
{
"Cooling": {
"path_match": "Cooling.*",
"mapping": {
"type": "text"
}
}
},
...
],
"properties": {
...
"Cooling": {
"type": "nested"
},
...
}
},
"listings": {
"_all": {
"enabled": false
},
"dynamic_templates": [
...
{
"Cooling": {
"path_match": "Cooling.*",
"mapping": {
"type": "text"
}
}
},
...
],
"properties": {
...
"Cooling": {
"type": "nested",
"properties": {
"key": {
"type": "text"
},
"value": {
"type": "text"
}
}
},
}
}
}
}
}