# Migrate from NEST 6.6 to ElasticSearch client 8

**URL:** <https://discuss.elastic.co/t/migrate-from-nest-6-6-to-elasticsearch-client-8/321288>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 15, 2022, 10:29am UTC](https://discuss.elastic.co/t/migrate-from-nest-6-6-to-elasticsearch-client-8/321288 "2022-12-15T10:29:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apokryfos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apokryfos/32/114730_2.png) [@apokryfos](https://discuss.elastic.co/u/apokryfos)\
**Post date:** [December 15, 2022, 10:29am UTC](https://discuss.elastic.co/t/migrate-from-nest-6-6-to-elasticsearch-client-8/321288/1 "2022-12-15T10:29:21Z")

</div>

I've recently upgraded my Elasticsearch server from 6.6 to 8.5 (quite a jump I know but it was long overdue). The main process to create/updated indexes is written in C# and was previously using NEST.

I originally asked this question at [c# - Migrate NEST 6.6 to Elasticsearch client 8. Unclear on how to define analyzers - Stack Overflow](https://stackoverflow.com/questions/74797726/migrate-nest-6-6-to-elasticsearch-client-8-unclear-on-how-to-define-analyzers) as well. My issue is I am trying to convert the following NEST code:

```auto
Client.CreateIndex(
  index => index.Settings(
    settings => settings.Analysis(
       analysis => analysis.TokenFilters(
       tokenFilter => tokenFilter.Synonym("synonym", syn => syn.SynonymsPath("analysis/synonym.txt"))
    ).Analyzers(analyzers => analyzers
       .Custom("mycustom", cust => cust
         .Filters("stop", "synonym").Tokenizer("standard")
        )
    )
  )
)

```

to the new client.  
I tried:

```auto
Client.Indices.Create(index => index.Settings(
 settings => setting.Analysis(
   analysis => analysis
     .Filter(tokenFilter => tokenFilter.Add(
        "synonym", new TokenFilter(new TokenFilterDefinitions(
            // This is where I start getting lost
            new Dictionary<string, ITokenFilterDefinition> {
            { "synonym", new SynonymTokenFilter() { // What are the keys meant to be?
                  SynonymsPath = "analysis/synonym.txt"
             } } }))))
     .Analyzer(analyzers =>
        analyzers.Custom("mycustom", cust => cust.Filter(new[] {"stop", "synonym"})
                 .Tokenizer("standard"))
        )) 
)

```

because this is the only way I could get the code to compile (and looked sort of sensible)  
but this creates the following request (fragment):

```auto
 "filter": {
        "synonym": {
          "synonym": {
            "synonyms_path": "analysis/synonym.txt",
            "type": "synonym"
          }
        },

```

Logically I would expect to be able to get around this by doing:

```auto
tokenFilter.Add("synonym", new SynonymTokenFilter() { 
   SynonymsPath = "analysis/synonym.txt"
})

```

but `SynonymTokenFilter` does not seem to match the type signature required for `Add(string, TokenFilter)` so I don't know what I can do.

---

<div class="post-metadata">

**Author:** ![stevejgordon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevejgordon/32/80912_2.png) [@stevejgordon](https://discuss.elastic.co/u/stevejgordon)\
**Post date:** [December 15, 2022, 3:15pm UTC](https://discuss.elastic.co/t/migrate-from-nest-6-6-to-elasticsearch-client-8/321288/2 "2022-12-15T15:15:36Z")

</div>

Hi, @apokryfos.

Thanks for raising this. Unfortunately, this is a blocking bug, and I've [opened an issue](https://github.com/elastic/elasticsearch-net/issues/7118) for us to review the code-generation of the token filter types.

---

<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:** [January 12, 2023, 3:16pm UTC](https://discuss.elastic.co/t/migrate-from-nest-6-6-to-elasticsearch-client-8/321288/3 "2023-01-12T15:16:26Z")

</div>

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