我尝试对带有标题的结果进行排序,但是无法正常工作。
查询:
GET /products/_search
{
"sort": [
{ "title.keyword": { "order": "desc" }}
],
"query": {
....
},
}
映射
"mappings" : {
"properties" : {
...
"title" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
...
}
}
结果
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 826,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : "products",
"_type" : "_doc",
"_id" : "1457580605505",
"_score" : null,
"_source" : {
"id" : 1457580605505,
"title" : "Étui-portefeuille multifonction pour iPhone", <-----
"body_html" : "description here",
在谷歌搜索后,我没有找到适合我的情况的正确答案。可能是因为我使用的是ES7和与之不兼容的解决方案。
我有多个以Z ...开头的产品
谢谢
答案 0 :(得分:1)
É在字符排序中排在Z之后。 (É与E不同)。当您想要对某些弹性字符串进行排序时,应对字段应用规范化器以实现自然排序。
您应该转到此文档页面:normalizer
在您的情况下,因为您使用法语,所以规范化器应由小写字母和ascii_folding过滤器组成。因此,文档页面中的示例应完全符合您的需求。