我使用 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/