我正在尝试将干草堆默认设置更改为非常简单的内容:
'settings': {
"analyzer": "spanish"
}
重建索引后,它看起来就正确了:
$ curl -XGET 'http://localhost:9200/haystack/_settings?pretty=true'
{
"haystack" : {
"settings" : {
"index.analyzer" : "spanish",
"index.number_of_shards" : "5",
"index.number_of_replicas" : "1",
"index.version.created" : "191199"
}
}
但是,当使用一些停用词测试它时,它无法按预期工作,它应该过滤掉“esto”和“que”,而是从英语停用词中过滤出“is”和“a”:
$ curl -XGET 'localhost:9200/haystack/_analyze?text=esto+is+a+test+que&pretty=true'
{
"tokens" : [ {
"token" : "esto",
"start_offset" : 0,
"end_offset" : 4,
"type" : "<ALPHANUM>",
"position" : 1
}, {
"token" : "test",
"start_offset" : 10,
"end_offset" : 14,
"type" : "<ALPHANUM>",
"position" : 4
}, {
"token" : "que",
"start_offset" : 15,
"end_offset" : 18,
"type" : "<ALPHANUM>",
"position" : 5
} ]
而且只有当我在查询中指定分析器时,它才有效:
$ curl -XGET 'localhost:9200/haystack/_analyze?text=esto+is+a+test+que&analyzer=spanish&pretty=true'
{
"tokens" : [ {
"token" : "is",
"start_offset" : 5,
"end_offset" : 7,
"type" : "<ALPHANUM>",
"position" : 2
}, {
"token" : "test",
"start_offset" : 10,
"end_offset" : 14,
"type" : "<ALPHANUM>",
"position" : 4
} ]
知道我在做什么错吗?
谢谢。
最佳答案
它应该是
"settings": {
"index.analysis.analyzer.default.type" : "spanish"
}
关于elasticsearch - Elasticsearch Analyzer从索引设置中忽略,仅在直接在查询中指定时才起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13572822/