【问题标题】:Elasticsearch and Spanish AccentsElasticsearch 和西班牙口音
【发布时间】:2015-01-16 23:52:17
【问题描述】:

我正在尝试使用 elasticsearch 来索引有关研究论文的一些数据。但我不喜欢口音。例如,如果我使用:

GET /_analyze?tokenizer=standard&filter=asciifolding&text="Boletínes de investigaciónes"我明白了

{
   "tokens": [
      {
         "token": "Bolet",
         "start_offset": 1,
         "end_offset": 6,
         "type": "<ALPHANUM>",
         "position": 1
      },
      {
         "token": "nes",
         "start_offset": 7,
         "end_offset": 10,
         "type": "<ALPHANUM>",
         "position": 2
      },
      {
         "token": "de",
         "start_offset": 11,
         "end_offset": 13,
         "type": "<ALPHANUM>",
         "position": 3
      },
      {
         "token": "investigaci",
         "start_offset": 14,
         "end_offset": 25,
         "type": "<ALPHANUM>",
         "position": 4
      },
      {
         "token": "nes",
         "start_offset": 26,
         "end_offset": 29,
         "type": "<ALPHANUM>",
         "position": 5
      }
   ]
}

我应该得到类似的东西

{
   "tokens": [
      {
         "token": "Boletines",
         "start_offset": 1,
         "end_offset": 6,
         "type": "<ALPHANUM>",
         "position": 1
      },
      {
         "token": "de",
         "start_offset": 11,
         "end_offset": 13,
         "type": "<ALPHANUM>",
         "position": 3
      },
      {
         "token": "investigacion",
         "start_offset": 14,
         "end_offset": 25,
         "type": "<ALPHANUM>",
         "position": 4
      }
   ]
}

我该怎么办?

【问题讨论】:

  • 我尝试在浏览器中发布 uri,我得到了预期的输出。 localhost:9200/…
  • 是的,在另一台机器上按预期工作,但在我的机器上不行!

标签: elasticsearch


【解决方案1】:

为防止形成额外的标记,您需要使用替代标记器,例如试试whitespace tokenizer

或者使用language analyzer 并指定语言。

【讨论】:

    【解决方案2】:

    您应该在分析器中使用 ASCII 折叠过滤器。

    例如,过滤器将 à 更改为 a。

    https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-asciifolding-tokenfilter.html

    【讨论】:

      猜你喜欢
      • 2016-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 2023-03-31
      相关资源
      最近更新 更多