我正在尝试将haystack默认设置更改为非常简单的内容:
'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
} ]
知道我做错了什么?
感谢。
答案 0 :(得分:1)
应该是
"settings": {
"index.analysis.analyzer.default.type" : "spanish"
}
答案 1 :(得分:1)
并将其应用于“干草堆”指数:
{
"haystack" : {
"settings" : {
"index.analysis.analyzer.default.type" : "spanish",
}
}
感谢imotov的建议。