我要升级到Nest 2(elasticsearch 1.x到2.3),但是请注意在发生重大变化时FuzzyMinimumSimilarity和OnFieldsWithBoost都消失了。我应该如何将以下代码替换为Nest v2?
new SearchDescriptor<T>().Type(searchTypes).Query(q =>q.QueryString(qs => qs.Query(fuzzy).FuzzyMinimumSimilarity(0.7)));
对于FuzzyMaxExpansions(0.7)
感谢进阶!
答案 0 :(得分:1)
这是fuzziness options available on query_string
query in NEST 2.x(使用最新的2.5.8)
var client = new ElasticClient();
var searchResponse = client.Search<MyDocument>(s => s
.Query(q => q
.QueryString(qs =>qs
.Fields(f => f
.Field(ff => ff.Name, 3)
.Field(ff => ff.Content, 0.5)
)
.Query("fuzzy")
.Fuzziness(Fuzziness.EditDistance(3))
.FuzzyMaxExpansions(2)
.FuzzyPrefixLength(4)
.FuzzyRewrite(MultiTermQueryRewrite.TopTerms(3))
)
)
);
产生
{
"query": {
"query_string": {
"query": "fuzzy",
"fuzzy_max_expansions": 2,
"fuzziness": 3,
"fuzzy_prefix_length": 4,
"fields": [
"name^3",
"content^0.5"
],
"fuzzy_rewrite": "top_terms_3"
}
}
}
还可以查看release blog post和breaking changes between 1.x and 2.x文档