# Syntax is overwriting when using .NET Elastic.Clients.ElasticSearch package

**URL:** <https://discuss.elastic.co/t/syntax-is-overwriting-when-using-net-elastic-clients-elasticsearch-package/339050>\
**Category:** Elasticsearch\
**Created:** [July 24, 2023, 8:06am UTC](https://discuss.elastic.co/t/syntax-is-overwriting-when-using-net-elastic-clients-elasticsearch-package/339050 "2023-07-24T08:06:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rottonscope](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@Rottonscope](https://discuss.elastic.co/u/Rottonscope)\
**Post date:** [July 24, 2023, 8:06am UTC](https://discuss.elastic.co/t/syntax-is-overwriting-when-using-net-elastic-clients-elasticsearch-package/339050/1 "2023-07-24T08:06:46Z")

</div>

Hello!

I'm new to using Elasticsearch and trying to get my head around the Query DSL for the .NET package: Elastic.Clients.Elasticsearch. I have a basic query set-up as such:

```auto
        Ids excludeIds = new Ids(new List<Id> { 351, 4826, 4823, 9, 10, 11 });

        var searchResponse = await client.SearchAsync<Document>(s => s
            .Index(INDEX_NAME)
            .From(0)
            .Size(50)
            .Query(q => q
                .Bool(b => b
                    .MustNot(m => m
                        .Ids(new IdsQuery() { Values = excludeIds })))
               .MultiMatch(mm => mm
                    .Query(text)
                    .Fields("description, title")
                ) 
            )
        );

```

However, it appears depending on the ordering of the Bool/MultiMatch queries, they appear to overwrite each other.

Can someone help me identify the correct syntax so that both queries would be included?

---

<div class="post-metadata">

**Author:** ![Rottonscope](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@Rottonscope](https://discuss.elastic.co/u/Rottonscope)\
**Post date:** [July 25, 2023, 7:34am UTC](https://discuss.elastic.co/t/syntax-is-overwriting-when-using-net-elastic-clients-elasticsearch-package/339050/2 "2023-07-25T07:34:52Z")

</div>

Just a quick update, seems I was able to resolve this by including the MultiMatch within the Bool itself, see here:

```auto
        Ids excludeIds = new Ids(new List<Id> { 351, 4826, 4823, 9, 10, 11 });

        var searchResponse = await client.SearchAsync<Document>(s => s
            .Index(INDEX_NAME)
            .From(0)
            .Size(50)
            .Query(q => q
                .Bool(b => b
                    .MustNot(m => m
                        .Ids(new IdsQuery() { Values = excludeIds }))
                    .Must(m => m
                        .MultiMatch(mm => mm
                            .Query(text)
                            .Fields("description, title")
                            )
                    )
                )
            )
        );

```

---

<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:** [August 22, 2023, 7:35am UTC](https://discuss.elastic.co/t/syntax-is-overwriting-when-using-net-elastic-clients-elasticsearch-package/339050/3 "2023-08-22T07:35:53Z")

</div>

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