Elasticsearch asciifolding无法正常工作

use*_*999 6 elasticsearch

我使用marvel插件创建了这个测试索引:

POST /test
{
   "index" : {
      "analysis" : {
         "analyzer" : {
            "folding": {
              "tokenizer": "standard",
              "filter":  [ "lowercase", "asciifolding" ]
            }
         }
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

而我正在制作这样的分析请求:

GET /test/_analyze?analyzer=folding&text=olá
Run Code Online (Sandbox Code Playgroud)

我得到的结果是:

{
    "tokens": [
          {
             "token": "ol",
             "start_offset": 0,
             "end_offset": 2,
             "type": "<ALPHANUM>",
             "position": 1
          }
       ]
}
Run Code Online (Sandbox Code Playgroud)

但我只需要一个"ola"代币而不是"ol".根据文档,它已正确配置:

https://www.elastic.co/guide/en/elasticsearch/guide/current/asciifolding-token-filter.html

我究竟做错了什么?

And*_*fan 8

试试这个,证明Elasticsearch最终做得很好.我怀疑Sense接口没有将正确的文本传递给分析器.

PUT /my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "folding": {
          "tokenizer": "standard",
          "filter":  [ "lowercase", "asciifolding" ]
        }
      }
    }
  },
  "mappings": {
    "test": {
      "properties": {
        "text": {
          "type": "string",
          "analyzer": "folding"
        }
      }
    }
  }
}

POST /my_index/test/1
{
  "text": "olá"
}

GET /my_index/test/_search
{
  "fielddata_fields": ["text"]
}
Run Code Online (Sandbox Code Playgroud)

结果:

   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "my_indexxx",
            "_type": "test",
            "_id": "1",
            "_score": 1,
            "_source": {
               "text": "olá"
            },
            "fields": {
               "text": [
                  "ola"
               ]
            }
         }
      ]
   }
Run Code Online (Sandbox Code Playgroud)

  • 那就对了!这是浏览器编码和感知界面的问题! (2认同)