带有模糊NEST的多重匹配查询-ElasticSearch [英] Multimatch query with Fuzzy NEST - ElasticSearch

查看:77
本文介绍了带有模糊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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆