# Migrating code from ElasticSearch.Net 7 to Elastic.Clients.Elasticsearch 8

**URL:** https://discuss.elastic.co/t/migrating-code-from-elasticsearch-net-7-to-elastic-clients-elasticsearch-8/322937
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [January 11, 2023, 2:03pm UTC](https://discuss.elastic.co/t/migrating-code-from-elasticsearch-net-7-to-elastic-clients-elasticsearch-8/322937 "2023-01-11T14:03:48Z")
**Posts on this page:** 2
**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 11, 2023, 2:03pm UTC](https://discuss.elastic.co/t/migrating-code-from-elasticsearch-net-7-to-elastic-clients-elasticsearch-8/322937/1 "2023-01-11T14:03:48Z")

</div>

Hi!

I’m rewriting our code for the new Elastic.Client.Elasticsearch and I’m trying to find some code examples how to do that.  
For example we have a lot of queries like this one:

```auto
> var response = _client.Search<TDocument>(s => s 
> .Index(_client.GetIndexName(TargetIndex.Current, IndexBaseName))
> .Query(q => (q
> .MultiMatch(mm => mm
> .Query(query)
> .Fields(fields => fields
> .Field(nameof(IDocumentModel.Title).ToLowerCamelCase(), 4)
> .Field(nameof(IDocumentModel.Preamble).ToLowerCamelCase()))) || q
> .MatchPhrase(m => m
> .Query(query)
> .Boost(2)
> .Field(nameof(IDocumentModel.Phonetics).ToLowerCamelCase())) || q
> .Match(m => m
> .Query(query)
> .Field(nameof(IDocumentModel.ContentLink).ToLowerCamelCase())) || q
> .MatchPhrasePrefix(m => m
> .Query(query)
> .Field(nameof(IDocumentModel.Id).ToLowerCamelCase()))) && +q
> .Match(t => t
> .Field(nameof(IDocumentModel.ParentTypeName).ToLowerCamelCase())
> .Query(type)))
> .Take(maxResults));

```

How would that be rewritten? I just cannot figure it out.

We also use the QueryContainer a lot from Nest, what is equal to that in the new code?

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 8, 2023, 2:04pm UTC](https://discuss.elastic.co/t/migrating-code-from-elasticsearch-net-7-to-elastic-clients-elasticsearch-8/322937/2 "2023-02-08T14:04:35Z")

</div>

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