This is a snippet of my mapping:
"products": {
"properties": {
"availability_date": {
"type": "date"
},
"banner": {
"properties": {
"id": {
"type": "long"
},
"copyright": {
"type": "keyword"
},
"url": {
"type": "keyword"
}
}
},
"categories": {
"type": "nested",
"properties": {
"id": {
"type": "long"
},
"category_type": {
"type": "keyword"
},
"name": {
"type": "text"
}
}
}
}
I want to sort my search result based on "categories.name"
I try to hit it with:
"sort":[
{
"categories.name":{
"order":"asc",
"nested_path":"categories"
}
}
],
But that does not work and return a message:
"Fielddata is disabled on text fields by default. Set fielddata=true on [categories.name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
So then I change the mapping to:
"products": {
"properties": {
"availability_date": {
"type": "date"
},
"banner": {
"properties": {
"id": {
"type": "long"
},
"copyright": {
"type": "keyword"
},
"url": {
"type": "keyword"
}
}
},
"categories": {
"type": "nested",
"properties": {
"id": {
"type": "long"
},
"category_type": {
"type": "keyword"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "sort_normalizer"
}
}
}
}
}
}
How do I do the sorting now? I tried this:
"sort":[
{
"categories.name.keyword":{
"order":"asc",
"nested_path":"categories.name"
}
}
],
That does not work with reason:
"[nested] failed to find nested object under path [categories.name]"
Some other map work but giving me unsorted result