我需要搜索包含多个字段的特殊字符的文本内容。 例如:name_text包含 - "你好,你好吗? "
如果我搜索单词"","是"我得到的结果却是" thow"我没有得到结果。
用于搜索已使用的
{"simple_query_string": {
"query": "thow",
"flags" : "OR|AND|PREFIX",
"analyzer": "snowball",
"fields": [ "name_text", "address_text" ]
}
我使用过nGram,这是我的代码
"settings":{ "index": {
"analysis": {
"analyzer": {
"autocomplete_term": {
"tokenizer": "autocomplete_edge",
"filter": [
"lowercase"
]
},
"autocomplete_search": {
"tokenizer": "keyword",
"filter": [
"lowercase"
]
}
},
"tokenizer": {
"autocomplete_edge": {
"type": "nGram",
"min_gram": 1,
"max_gram": 100
}
}
}
}
和映射
"name_text": {
"type": "string",
"analyzer": "autocomplete_term"
"search_analyzer": "autocomplete_search"
},
"address_text": {
"type": "string",
"analyzer": "autocomplete_term"
"search_analyzer": "autocomplete_search"
}
我的代码有什么问题。请帮帮我
答案 0 :(得分:0)
您需要模糊搜索才能匹配:
"simple_query_string": {
"query": "thow~1",
"flags": "OR|AND|PREFIX|FUZZY",
"analyzer": "snowball",
"fields": [
"name_text",
"address_text"
]
}