I'm just digging into aggregations and in my testing, I'm running into this problem:
"Fielddata is disabled on text fields by default. Set fielddata=true on [skuid] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
Ultimate, I want to be able to aggregate options of items (like sizes). Here's an example:
...
"options" : {
"size" : [
{
"description" : "Small",
"code" : "S"
},
{
"code" : "M",
"description" : "Medium"
},
{
"description" : "Large",
"code" : "L"
},
{
"code" : "XXL",
"description" : "Extra Large"
},
{
"code" : "XXL",
"description" : "XXL"
}
]
}
...
I found this in the docs:
https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html
But it's not entirely clear to me how to change the mapping of that data (right now it's just the default) so that it can be used for aggregation. Anyone got any ideas?
Once I do have the mapping figured out, I'm thinking something like this should work?
"aggs" : {
"sizes" : {
"terms" : {
"field" : "options.size.description"
}
}
}