使用模糊 NEST 进行多匹配查询 - ElasticSearch [英] Multimatch query with Fuzzy NEST - ElasticSearch
本文介绍了使用模糊 NEST 进行多匹配查询 - ElasticSearch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了以下查询来检查一个值中的多个字段并且它有效:
I wrote the following query to check multiple fields from a value and it's work:
var searchResponse = client.Search<Document>(s => s
.Query(q => q
.MultiMatch(a => a
.Fields(f => f
.Field(p => p.Attachment.Content)
.Field(p => p.FileName))
.Query(queryValue))));
我会获得相同的结果(在字段 Attachment.Content 和 FileName 中搜索 queryValue),但使用模糊机制(例如,如果 queryValue 是esting",我也会返回文件名为testing"的结果)).
I would achieve the same result (search the queryValue in fields Attachment.Content and FileName) but with the Fuzzy mechanism (for example, if queryValue is "esting" I would get back also a result with filename "testing").
非常感谢!C# netCore 3.1
Thanks a lot! C# netCore 3.1
推荐答案
在 Elasticsearch 中使用字符进行搜索.
Search using characters in Elasticsearch.
您可以对结果使用以下查询:(注意:必须阅读评论)
You can use the following query for your results: (Note: must read the comments)
//finds all strings starting with queryValue
//string queryValue = queryValue + "*";
//finds all strings containing queryValue
string queryValue = "*" + queryValue + "*";
//finds all strings ending with queryValue
//string queryValue = "*" + queryValue;
var searchResponse = client.Search<Document>(s => s
.Query(q => q
.QueryString(qs => qs
.Query(queryValue)
.Fields(f => f
.Field(Attachment.Content)//first field
.Field(FileName)//second field
))));
这篇关于使用模糊 NEST 进行多匹配查询 - ElasticSearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文