0

I'm upgrading to Nest 2 (elasticsearch 1.x to 2.3), but notice on breaking changes that FuzzyMinimumSimilarity and OnFieldsWithBoost are gone. How should i replace this code below to Nest v2?

new SearchDescriptor<T>().Type(searchTypes).Query(q =>q.QueryString(qs => qs.Query(fuzzy).FuzzyMinimumSimilarity(0.7)));

And for FuzzyMaxExpansions(0.7)

Deep
  • 929
  • 2
  • 16
  • 32
Gonzalo
  • 322
  • 1
  • 3
  • 13

1 Answers1

1

Here are the fuzziness options available on query_string query in NEST 2.x (use latest 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))
        )
    )
);

which yields

{
  "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"
    }
  }
}

Also take a look at the release blog post and breaking changes between 1.x and 2.x documentation

Russ Cam
  • 124,184
  • 33
  • 204
  • 266
  • thanks for your answer, but still i don't see the replacement for FuzzyMinimumSimilarity(0,7)...is there something equivalent for this? – Gonzalo Feb 28 '19 at 11:39
  • 1
    The replace is `Fuzziness`. Take a look at https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_search_changes.html#_changes_to_queries for `fuzzy_min_sim` – Russ Cam Mar 05 '19 at 05:32