Elasticsearch asciifolding 无法正常工作

标签 elasticsearch

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

POST /test
{
   "index" : {
      "analysis" : {
         "analyzer" : {
            "folding": {
              "tokenizer": "standard",
              "filter":  [ "lowercase", "asciifolding" ]
            }
         }
      }
   }
}

我正在像这样发出分析请求:

GET /test/_analyze?analyzer=folding&text=olá

我得到的结果是:

{
    "tokens": [
          {
             "token": "ol",
             "start_offset": 0,
             "end_offset": 2,
             "type": "<ALPHANUM>",
             "position": 1
          }
       ]
}

但我需要一个“ola”标记而不是“ol”。根据文档,它已正确配置:

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

我做错了什么?

最佳答案

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

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"]
}

结果:

   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "my_indexxx",
            "_type": "test",
            "_id": "1",
            "_score": 1,
            "_source": {
               "text": "olá"
            },
            "fields": {
               "text": [
                  "ola"
               ]
            }
         }
      ]
   }

关于Elasticsearch asciifolding 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31282783/

相关文章:

search - Elasticsearch完成建议者字段包含逗号分隔的值

python-3.x - ElasticSearch查询传递python动态变量

elasticsearch - 在 Elasticsearch 中排序

python - 使用python从 Elasticsearch 获取数据表可视化

elasticsearch - 如何在Kibana中搜索json字符串属性中的子字符串( Elasticsearch )?

elasticsearch - Elasticsearch-我想搜索用户搜索的确切生日(例如03221989)和即将到来的生日

elasticsearch - Kibana正在获取此信息,parsing_exception:没有为[_source]错误注册[query]

java - 按名字或姓氏以及特定的相关 ID 搜索?

elasticsearch - 如何对精确,语音和模糊查询赋予不同的权重?

elasticsearch - 在Elasticsearch类型中添加字段映射的成本