【问题标题】:Elasticsearch modify asciifoldingElasticsearch 修改 asciifolding
【发布时间】:2018-04-19 10:02:55
【问题描述】:

ASCII 折叠标记过滤器将“Ə”/“ə”(U+018F / U+0259) 字符折叠为“A”/“a”。我需要修改或添加折叠到“E”/“e”。 char_filter 没有帮助,也不会保留原件

添加分析器:

curl -XPUT 'localshot:9200/myix/_settings?pretty' -H 'Content-Type: application/json' -d'
{
        "analysis" : {
            "analyzer" : {
                "default" : {
                    "tokenizer" : "standard",
                    "filter" : ["standard", "my_ascii_folding"]
                }
            },
            "filter" : {
                "my_ascii_folding" : {
                    "type" : "asciifolding",
                    "preserve_original" : true
                }
            }
        }
}
'

测试结果:

http://localhost:9200/myix/_analyze?text=üöğıəçşi_ÜÖĞIƏÇŞİ&filter=my_ascii_folding

{
  "tokens": [
    {
      "token": "uogiacsi_UOGIACSI",
      "start_offset": 0,
      "end_offset": 17,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "üöğıəçşi_ÜÖĞIƏÇŞİ",
      "start_offset": 0,
      "end_offset": 17,
      "type": "<ALPHANUM>",
      "position": 0
    }
  ]
}

【问题讨论】:

标签: elasticsearch unicode full-text-search ascii


【解决方案1】:

查看 Lucene 的 ASCIIFoldingFilter.java 源文件时,Ə 似乎确实被折叠成 E 而不是 A。即使是 ICU folding filter 是类固醇上的 asciifolding,也会进行相同的折叠。

然而,这个主题有一个interesting discussion,似乎考虑到发音,它应该被折叠成一个a而不是e

在英语或法语 Wikipedia 上快速搜索,它当前已折叠,显示它已折叠为 a!我本来期望一个基于正字法的 e,但在发音方面是有意义的(至少在英语中)。

其他人甚至认为ae 都没有意义:

这似乎是一个非常糟糕的决定。我不认为 ə 应该对 a 或 e 弃牌。

无论如何,我认为除了使用 char_filter 或 extending the ASCIIFoldingFilter 并自己将其捆绑到 ES 分析插件中之外,没有其他方法。

【讨论】:

  • 这个运气好吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-17
  • 1970-01-01
  • 2020-12-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多