如何为 elasticsearch icu_collation_keyword 字段编写排序规则,字母最多优先?

问题描述 投票:0回答:1

我想编写一个规则参数来自定义排序行为,而不是使用其他语言环境选项,而字母表具有最高优先级。

对于文本值,1232 美元,Abi,7232 英镑,87343,Karthik

我想要归类规则,具有以下排序顺序

  • 阿比
  • 卡尔提克
  • 1232 美元
  • 7232英镑
  • 87343

到目前为止,我已尝试使用以下映射

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "name": {   
        "type": "text",
        "fields": {
          "sort": {  
            "type": "icu_collation_keyword",
            "index": false,
            "language" : "en"
          }
        }
      }
    }
  }
}

上面的locale选项(language)代替rules选项,按以下顺序排序

  • 1232 美元
  • 7232英镑
  • 87343
  • 阿比
  • 卡尔提克

有人可以让我知道如何编写排序规则,以便字母优先于其他字母

字母 -> 空格 -> 标点 -> 符号 -> 货币 -> 数字 -> 其他

提前致谢。

sorting elasticsearch collation
1个回答
0
投票

嗨@all 下面的排序规则设置适用于用例。

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "name": {   
        "type": "text",
        "fields": {
          "sort": {  
            "type": "icu_collation_keyword",
            "index": false,
            "rules" :   "[reorder Latn digit space punct currency others]",
            "alternate" : "shifted"
          }
        }
      }
    }
  }
}
enter code here

谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.