我对名称字段有以下定义:
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
如何按字母顺序排序?
我正在尝试以下
{
"query": {
"match": {
"name": "Shoes"
}
},
"sort": {
"keyword": {
"order": "asc"
}
},
"size": 10,
"from": 0,
"sort": []
}
但不知何故,这种排序似乎根本没有做任何事情。
我已经提到了这些线程,但它们似乎对我的情况没有帮助。
您需要参考
name.keyword
子字段,并且您的搜索中有两个不同的 sort
部分,请删除空的部分:
{
"query": {
"match": {
"name": "Shoes"
}
},
"sort": {
"name.keyword": { <---- change this
"order": "asc"
}
},
"size": 10,
"from": 0,
"sort": [] <---- remove this
}