# .NET new client migration issue

**URL:** <https://discuss.elastic.co/t/net-new-client-migration-issue/364774>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 12, 2024, 12:31pm UTC](https://discuss.elastic.co/t/net-new-client-migration-issue/364774 "2024-08-12T12:31:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jahedi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jahedi/32/135254_2.png) [@jahedi](https://discuss.elastic.co/u/jahedi)\
**Post date:** [August 12, 2024, 12:31pm UTC](https://discuss.elastic.co/t/net-new-client-migration-issue/364774/1 "2024-08-12T12:31:00Z")

</div>

Hi,  
I am currently using v7 Elastic .NET client `Nest`. I want to migrate to the new `Elastic.Client.Elasticsearch` package v8. I have problems with this package's documentations and I can not find proper docs to use this package so I had to ask my question here.

How can I rewrite the following query writen with Nest using the new .NET client?

```cs
var suggestResponse = await _client.SearchAsync<MyDocument>(s => s
    .Suggest(su => su
        .Phrase("simple_phrase", ph => ph
            .Text(searchPhrase)
            .Field(f => f.Title.Suffix("shingle"))
            .Size(5)
            .Confidence(1)
            .DirectGenerator(dg => dg
                .Field(f => f.Title.Suffix("shingle"))
                .PrefixLength(0)
            )
            .MaxErrors(2)
            .Collate(co => co
                .Query(q => q
                    .Source("{\"match\": {\"title\": {\"query\": \"{{suggestion}}\", \"fuzziness\": \"1\", \"operator\": \"and\"}}}")
                )
                .Prune(false)
            )
        )
    )
);

```

Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [August 12, 2024, 1:37pm UTC](https://discuss.elastic.co/t/net-new-client-migration-issue/364774/2 "2024-08-12T13:37:59Z")

</div>

@jahedi Something like this should work:

```csharp
var suggestResponse = await _client.SearchAsync<MyDocument>(s => s
    .Suggest(su => su
        .Suggesters(sus => sus
            .Add("simple_phrase", sug => sug
                .Phrase(ph => ph
                    .Text(searchPhrase)
                    .Field(f => f.Title.Suffix("shingle"))
                    .Size(5)
                    .Confidence(1)
                    .DirectGenerator(dg => dg
                        .Field(f => f.Title.Suffix("shingle"))
                        .PrefixLength(0)
                    )
                    .MaxErrors(2)
                    .Collate(co => co
                        .Query(q => q
                            .Source("{\"match\": {\"title\": {\"query\": \"{{suggestion}}\", \"fuzziness\": \"1\", \"operator\": \"and\"}}}")
                        )
                        .Prune(false)
                    )
                )
            )
        )
    )
);

```

While there is little documentation for the new client, the API almost always maps closely to the structure of the REST API.

---

<div class="post-metadata">

**Author:** ![jahedi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jahedi/32/135254_2.png) [@jahedi](https://discuss.elastic.co/u/jahedi)\
**Post date:** [August 13, 2024, 4:46am UTC](https://discuss.elastic.co/t/net-new-client-migration-issue/364774/3 "2024-08-13T04:46:24Z")

</div>

@flobernd Thanks for your response.  
This code does not have syntax errors but I get this exception after executing this query:

```auto
Message: Request failed to execute. Call: Status code 400 from: POST /_search?pretty=true&error_trace=true&typed_keys=true. ServerError: Type: parsing_exception Reason: "suggester[phrase] doesn't support field [text]"

{Unsuccessful (400) low level call on POST: /_search?pretty=true&error_trace=true&typed_keys=true Exception: Request failed to execute. Call: Status code 400 from: POST /_search?pretty=true&error_trace=true&typed_keys=true. ServerError: Type: parsing_exception Reason: "suggester[phrase] doesn't support field [text]"}

```

I had no such problem with the previous code

---

<div class="post-metadata">

**Author:** ![jahedi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jahedi/32/135254_2.png) [@jahedi](https://discuss.elastic.co/u/jahedi)\
**Post date:** [August 14, 2024, 5:14am UTC](https://discuss.elastic.co/t/net-new-client-migration-issue/364774/4 "2024-08-14T05:14:15Z")

</div>

Can somebody please answer this question? I really can't solve and debug this issue by myself because of the lack of documentations and examples in this area.

Thanks in advance.
