【发布时间】:2014-12-18 16:06:12
【问题描述】:
我目前正在使用此端点执行搜索并请求:
elasticserver.com/citysuggest/_suggest -d {
"result": {
"text": "Chicago",
"completion": {
"field": "autoCompleteName"
}
}
这是我的索引映射:
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"index": {
"mapper": {
"dynamic": false
}
},
"analysis": {
"analyzer": {
"str_search_analyzer": {
"tokenizer": "standard",
"filter": ["standard", "str_delimiter", "asciifolding", "porter_stem"]
},
"str_index_analyzer": {
"tokenizer": "standard",
"filter": ["standard", "str_delimiter", "asciifolding", "porter_stem"],
"char_filter": "html_strip"
}
},
"filter": {
"str_delimiter": {
"type": "word_delimiter",
"generate_word_parts": true,
"catenate_words": true,
"catenate_numbers": true,
"catenate_all": true,
"split_on_case_change": true,
"preserve_original": true,
"split_on_numerics": true,
"stem_english_possessive": true
}
}
}
},
"mappings": {
"city": {
"_source": {
"enabled": false
},
"dynamic": false,
"properties": {
"_all": {
"enabled": false
},
"autoCompleteName": {
"type": "completion",
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer"
}
}
}
}
}
当我搜索“芝加哥”时,它会返回预期的结果,因为它找到了芝加哥的匹配项,但是,当我搜索“芝加哥”时,它不会返回任何内容。我一生都无法弄清楚我需要更改什么以使搜索不区分大小写。如果用户键入“ChiCAgO”,它应该返回我的芝加哥结果,而我什么也得不到。
为了测试我的分析器,我运行了这个:
elasticserver.com/citysuggest/_analyze?text=ChicaGo&pretty
我得到了看起来像正确标记的值。
{
"tokens": [
{
"token": "chicago",
"start_offset": 0,
"end_offset": 7,
"type": "<ALPHANUM>",
"position": 1
}
]
}
【问题讨论】:
标签: elasticsearch