我正在使用弹性搜索6.5.x,并在自定义分析器下添加了多个。谈到停用词分析器,当我使用 _analyze 进行检查时,我能够正确获得响应。当谈到我的索引的现实时,即使输入了停用词,搜索框也会为我提供结果。我要发布索引,为此映射任何解决方案。
索引:
PUT some-index
{
"settings": {
"index": {
"number_of_shards": 4,
"number_of_replicas": 1,
"refresh_interval": "60s",
"analysis" : {
"analyzer" : {
"my_analyzer" : {
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "my_snow", "my_stop","my_synonym"]
}
},
"filter" : {
"my_snow" : {
"type" : "snowball",
"language": "English"
},
"my_stop": {
"type":"stop",
"stopwords_path":"/home/elasticsearch-6.5.0/config/stopwords/stopwords.txt"
},
"my_synonym" : {
"type" : "synonym",
"synonyms_path" : "/home/elasticsearch-6.5.0/config//analysis/synonyms.txt"
}
}}
}
},
"mappings": {
"doc": {
"_source": {
"enabled": true
},
"properties": {
"title": {
"type": "text",
"index": "true",
"store": true,
"analyzer": "my_analyzer"
},
"content": {
"type": "text",
"index": "true",
"store": true,
"analyzer": "my_analyzer"
},
"url": {
"type": "keyword",
"index": "false",
"store": true
},
"host": {
"type": "keyword",
"index": "true",
"store": true
},
"seed": {
"type": "keyword",
"index": "true",
"store": true
}
}}
}
}
我需要使用的查询
POST /some-index/_search
{
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : "test" /* Tested with and,between*/
}
},
"filter" : {
"term" : { "seed" : "ghi" }
}
}
}
}
经过/ _analyze测试的效果很好
POST some-index/_analyze
{
"analyzer": "my_analyzer",
"text":"Hi this is Ramy."
}