【发布时间】:2017-06-30 08:30:37
【问题描述】:
我想使用 icu_collation 过滤器对 elasticsearch 结果文档进行排序。所以我有 索引设置:
"settings": {
"analysis": {
"analyzer": {
"ducet_sort": {
"tokenizer": "keyword",
"filter": [ "icu_collation" ]
}
}
}
}
和映射
"mappings": {
"card": {
"properties": {
"title": {
"type": "text",
"fields": {
"sort": {
"type": "text",
"analyzer": "ducet_sort",
"index": false
}
}
}
}}}
和查询:
{
"sort": ["title.sort"]
}
但是查询失败:
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [title.sort] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
}
在文档中,建议的排序数据类型是 keyword。但是数据类型 keyword 不支持分析器。另外不推荐使用fielddata:
那么有没有一种方法可以在弹性搜索中使用一些特定的排序规则对文档进行排序,例如icu_collation 没有 fielddata=true?
谢谢。
【问题讨论】:
-
在启用 fielddata 之前,请考虑为什么要使用文本字段进行聚合、排序或在脚本中。这样做通常没有意义。那么,为什么需要它?
-
我需要按 icu_collation 排序。我如何使用不同的数据类型来做到这一点,例如关键字?
-
他们只是提议启用 fielddata elastic.co/guide/en/elasticsearch/plugins/current/…
标签: elasticsearch