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

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:

        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?

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

        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")
                            )
                    )
                )
            )
        );

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