[英]Elastic search - text search not working
I need to search a text content with special characters for multiple fields. 我需要搜索具有多个字段的特殊字符的文本内容。 eg: name_text contains - "Hello , How are you ? " 例如:name_text包含 - “你好,你好吗?”
if i search the word "how","are" i got the result but incase of "thow" i am not getting the result. 如果我搜索“如何”这个词,“是”我得到了结果,但是因为“thow”我没有得到结果。
for searching used 用于搜索
{"simple_query_string": {
"query": "thow",
"flags" : "OR|AND|PREFIX",
"analyzer": "snowball",
"fields": [ "name_text", "address_text" ]
}
I have used nGram and here is my code 我使用过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
}
}
}
}
and mapping 和映射
"name_text": {
"type": "string",
"analyzer": "autocomplete_term"
"search_analyzer": "autocomplete_search"
},
"address_text": {
"type": "string",
"analyzer": "autocomplete_term"
"search_analyzer": "autocomplete_search"
}
Is there anything wrong in my code. 我的代码有什么问题。 Please help me 请帮我
You need fuzzy search for that to match: 你需要模糊搜索才能匹配:
"simple_query_string": {
"query": "thow~1",
"flags": "OR|AND|PREFIX|FUZZY",
"analyzer": "snowball",
"fields": [
"name_text",
"address_text"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.