ElasticSearch - NEST 搜索部分字符串多匹配

我有一个应用程序(.net core + ReactJS),我必须弄清楚并制作一个 mod,但后来发现它使用了很多我不熟悉的技术,在这种情况下是 ElasticSearch . 目前,搜索术语 micro 不会返回任何内容,因为显然它正在寻找完全匹配,但我想要实现的是,对 micro 的搜索应该返回 microsoft、microStrategy...以及任何包含名称中的“micro”,我如何在以下代码中实现它?我试着做一些研究,我看到像 ngram、分析器、query_string 或 QueryString 之类的东西......不知道从哪里开始。请帮忙。

public SearchDescriptor<ProductRecord> BuildSearchDescriptor(
            string productType,string name,int page,int pageSize,Dictionary<string,List<string>> filters)
        {
            ValidateProductType(productType);
            var collection = ProductTypeToCollection[productType];

            var searchDescriptor = new SearchDescriptor<ProductRecord>()
                .Index(collection)
                .From(page * pageSize)
                .Size(pageSize)
                .Query(q => q
                    .Bool(bq => bq
                        .Must(m => m
                            .MultiMatch(c => c
                                    .Query(name)
                                    .Fields(ff => ff
                                        .Field(f => f.Product,boost: ProductBoost)
                                        .Field(f => f.Manufacturer,boost: ManufacturerBoost)
                                        .Field(f => f.Version)
                                        .Field(f => f.Id,boost: 50)
                                    )
                                    .Type(TextQueryType.CrossFields)
                                //.Type(TextQueryType.BestFields)
                            ))
                        .Filter(fq => AddFilters(fq,filters))
                    )
                )
                .Sort(ss => ss
                        .Descending(SortSpecialField.Score)
                        .Ascending(p => p.Product.Suffix("keyword"))
                        .Ascending(p => p.Manufacturer.Suffix("keyword"))
                        .Descending(p => p.Version.Suffix("keyword"))
                    /*.Script(sc => sc
                        .Type("number")
                        .Descending()
                        .Script(script => script
                            .Source("doc['VERSION'].value")))
                            */
                );
            return searchDescriptor;
        }
}
java21710397 回答:ElasticSearch - NEST 搜索部分字符串多匹配

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/592.html

大家都在问