[英]Elatisearch match_phrase_prefix query, with exact prefix match
I have a match_phrase_prefix query, which works as expected.我有一个 match_phrase_prefix 查询,它按预期工作。 But when the users passes any special characters at the end of the keyword, ES ignores these characters, and still returns the result.
但是当用户在关键字末尾传递任何特殊字符时,ES 忽略这些字符,仍然返回结果。
query{ match_phrase_prefix:{ content: { query: searchTerm } } }
I am using this query to search for prefix.我正在使用此查询来搜索前缀。 If i pass a term like overflow@#@#!!
如果我通过像溢出这样的术语@#@#!! ES is returning me all the results with the word overflow in it.
ES 将所有结果返回给我,其中包含溢出一词。 But instead i want to make an exact prefix match, where the special characters are not ignored.
但相反,我想进行精确的前缀匹配,其中特殊字符不会被忽略。 The search term could be of multiple words as well stack overflow search .
搜索词可以是多个词,也可以是堆栈溢出搜索。 How could i make ES search of prefix_match without ignoring the special_chars.
我如何在不忽略 special_chars 的情况下对 prefix_match 进行 ES 搜索。
You can use keyword
analyzer when defining your query.您可以在定义查询时使用
keyword
分析器。
{
"query": {
"match_phrase_prefix": {
"content": {
"query": "overflow@#@#!!",
"analyzer": "keyword"
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.