带有小写过滤器的自定义分析器无法按预期工作
Custom analyzer with lowercase filter doesn't work as expected
我有一个名为 custom_raw_analyzer
的简单自定义分析器,如下所示:
$ curl 'http://localhost:9200/test/_settings?pretty'
"test" : {
"settings" : {
"index" : {
"uuid" : "_M-KXnZSQXyFH7cqbh6lsw",
"number_of_replicas" : "1",
"analysis" : {
"analyzer" : {
"custom_raw_analyzer" : {
"type" : "custom",
"filters" : [ "lowercase" ],
"tokenizer" : "keyword"
}
}
},
"number_of_shards" : "5",
"refresh_interval" : "10s",
"version" : {
"created" : "1030499"
}
}
}
}
}
但是当我对一个随机字符串进行测试时,输出的标记不是小写的:
$ curl -XGET 'localhost:9200/test/_analyze?analyzer=custom_raw_analyzer' -d "This Is A Test"
结果:
{
"tokens": [
{
"token": "This Is A Test",
"start_offset": 0,
"end_offset": 14,
"type": "word",
"position": 1
}
]
}
任何人都可以解释为什么吗?
我认为你打错了:
"filters" : [ "lowercase" ],
不应有尾随 "s":
"filter" : [ "lowercase" ],
我有一个名为 custom_raw_analyzer
的简单自定义分析器,如下所示:
$ curl 'http://localhost:9200/test/_settings?pretty'
"test" : {
"settings" : {
"index" : {
"uuid" : "_M-KXnZSQXyFH7cqbh6lsw",
"number_of_replicas" : "1",
"analysis" : {
"analyzer" : {
"custom_raw_analyzer" : {
"type" : "custom",
"filters" : [ "lowercase" ],
"tokenizer" : "keyword"
}
}
},
"number_of_shards" : "5",
"refresh_interval" : "10s",
"version" : {
"created" : "1030499"
}
}
}
}
}
但是当我对一个随机字符串进行测试时,输出的标记不是小写的:
$ curl -XGET 'localhost:9200/test/_analyze?analyzer=custom_raw_analyzer' -d "This Is A Test"
结果:
{
"tokens": [
{
"token": "This Is A Test",
"start_offset": 0,
"end_offset": 14,
"type": "word",
"position": 1
}
]
}
任何人都可以解释为什么吗?
我认为你打错了:
"filters" : [ "lowercase" ],
不应有尾随 "s":
"filter" : [ "lowercase" ],