# Different behavior in multi\_match after replacing NEST with Elastic.Clients.Elasticsearch

**URL:** <https://discuss.elastic.co/t/different-behavior-in-multi-match-after-replacing-nest-with-elastic-clients-elasticsearch/373495>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [January 22, 2025, 8:23am UTC](https://discuss.elastic.co/t/different-behavior-in-multi-match-after-replacing-nest-with-elastic-clients-elasticsearch/373495 "2025-01-22T08:23:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbooh](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mbooh](https://discuss.elastic.co/u/mbooh)\
**Post date:** [January 22, 2025, 8:23am UTC](https://discuss.elastic.co/t/different-behavior-in-multi-match-after-replacing-nest-with-elastic-clients-elasticsearch/373495/1 "2025-01-22T08:23:43Z")

</div>

Hi!

I just removed NEST and started to use Elastic.Clients.Elasticsearch I get a really strange behavior.

The mulit\_match looks like this:

```auto
"multi_match": {
                "operator": "and",
                "query": "Annika Jöns",
                "type": "cross_fields"
              }

```

This query gives me a hit in the NEST created index but not in the Elastic.Clients.Elasticsearch index.  
Search for "Jönsson" gives me a hit in both indexes also "Annika Jons" gives me a hit in both indexes. So it seems to have something to do with the "ö" when there is a two part multi\_match.  
Any suggerstions why this is happening?  
I do the search from Kibana and get the same behavior so it seems like it has nothing to do with the query using NEST och Elastic.Clients from C#.

Can I compare the indicies in Kibana, or is it something else I'm missing?

In NEST i create the index like this:

```auto
 var createIndexResponse = Indices.Create(indexName, createIndex => createIndex
     .Settings(settings => settings
         .NumberOfShards(1)
         .NumberOfReplicas(1)
         .Analysis(analysis => analysisSettings))
     .Timeout(TimeSpan.FromSeconds(60)));

```

In Elastic.Client.Elasticsearch I do like this:

```auto
var createIndexResponse = Indices.CreateAsync(indexName, createIndex => createIndex
    .Settings(settings => settings
        .NumberOfShards(1)
        .NumberOfReplicas(1)
        .Analysis(analysisSettings))
    .Timeout(new Duration(TimeSpan.FromSeconds(60))));

var createIndexResult = createIndexResponse.Result;

```

This is the code for analys settings:

```auto
 public class DefaultAnalyzerConfiguration : IAnalyzerConfiguration
 {
     public Dictionary<string, IAnalyzer> GetAnalyzers()
     {
         var analyzers = new Dictionary<string, IAnalyzer>
         {
             // Ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-standard-analyzer.html
             { Constants.DefaultQueryAnalyzerName, new StandardAnalyzer() },
             {
                 Constants.DefaultIndexAnalyzerName,
                 new CustomAnalyzer
                 {
                     Tokenizer = "standard",
                     Filter = new List<string>
                     {
                          "lowercase",
                          "english_stop",
                     },
                 }
             },
             {
                 Constants.AccentAnalyzerName,
                 new CustomAnalyzer
                 {
                     Tokenizer = "standard",
                     Filter = new List<string>
                     {
                         "lowercase",
                         "english_stop",
                         "asciifolding",
                     },
                 }
             },
             {
                 Constants.AccentEdgeNGramAnalyzerName,
                 new CustomAnalyzer
                 {
                     Tokenizer = "edgeNGramTokenizer",
                     Filter = new List<string>
                     {
                         "lowercase",
                         "english_stop",
                         "asciifolding",
                     },
                 }
             },
         };

         return analyzers;
     }

     public Dictionary<string, ITokenFilter> GetTokenFilters()
     {
         var tokenFilters = new Dictionary<string, ITokenFilter>
         {
             { "english_stop", new StopTokenFilter() { Stopwords = new[] { "_english_" } } },
         };

         return tokenFilters;
     }

     public Dictionary<string, ITokenizer> GetTokenizers()
     {
         var tokenizers = new Dictionary<string, ITokenizer>
         {
             {
                 "edgeNGramTokenizer",
                 new EdgeNGramTokenizer
                 {
                     MinGram = 1,
                     MaxGram = 30,
                     TokenChars = new List<TokenChar> { TokenChar.Letter, TokenChar.Digit }
                 }
             },
         };

         return tokenizers;
     }

     public Dictionary<string, INormalizer> GetNormalizers()
     {
         var normalizers = new Dictionary<string, INormalizer>
         {
             {
                 "keywordNormalizer",
                 new CustomNormalizer
                 {
                     CharFilter = new List<string>(),
                     Filter = new List<string>
                     {
                         "lowercase", "asciifolding"
                     },
                 }
             },
         };

         return normalizers;
     }
 }

```

Thanks!

/Kristoffer

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [January 24, 2025, 3:02pm UTC](https://discuss.elastic.co/t/different-behavior-in-multi-match-after-replacing-nest-with-elastic-clients-elasticsearch/373495/2 "2025-01-24T15:02:00Z")

</div>

Hi @mbooh :

It seems related to the analyzer settings. Could you get the result from

GET \<your\_index\>

for both ways of creating the index, so we can compare the analyzers?

Thanks!

---

<div class="post-metadata">

**Author:** ![mbooh](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mbooh](https://discuss.elastic.co/u/mbooh)\
**Post date:** [January 24, 2025, 3:33pm UTC](https://discuss.elastic.co/t/different-behavior-in-multi-match-after-replacing-nest-with-elastic-clients-elasticsearch/373495/3 "2025-01-24T15:33:37Z")

</div>

Thank you very much for that tip Carlos!

I found this in the old one:

```auto
"title": {
          "type": "text",
          "analyzer": "accentEdgeNGramAnalyzer",
          "search_analyzer": "accentQueryAnalyzer"
        },

```

and this in the new:

```auto
"title": {
          "type": "text",
          "analyzer": "accentEdgeNGramAnalyzer",
          "search_analyzer": "defaultIndexAnalyzer"
        },

```

Changed to accentQueryAnalyzer in the new and now we are back on track.

Thanks!

/Kristoffer

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 21, 2025, 3:34pm UTC](https://discuss.elastic.co/t/different-behavior-in-multi-match-after-replacing-nest-with-elastic-clients-elasticsearch/373495/4 "2025-02-21T15:34:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
