Nest query search with AND

I'd like to convert this

GET /financialfirms/_search?q="Danske" AND "Bank"

into DSL but can't find out how. Anyone wanna help?

Right now every query I've made gives a result for "Danske" OR "Bank". I've tried different kind of querys and analyzers but I don't get it.

My solution (thats not working correctly) looks like this

        public ElasticClient EsClient()
        {
            var uri = new Uri("http://localhost:9200");
            var pool = new SingleNodeConnectionPool(uri);
            var settings = new ConnectionSettings(pool).DefaultIndex("financialfirms");
            var client = new ElasticClient(settings);
            return client;
        }
public async Task<GenericResponse<FinancialFirmDto>> GetFinancialFirmByNameES(string name)
        {
          var searchResponse = await EsClient().SearchAsync<FinancialFirmDto>(s => s                
                .Query(q => q
                    .Match(m => m
                      .Field(f => f.Name)
                      .Query(name)
                  )));
        ...
        }

Edit
Also, forgot to mention, the input will not be set to specific words like “Danske” and “Bank”, they are just existing examples. The input is user defined (full-text search I guess) and could be any words and amount , so I can’t really use a bool query with terms (what I can tell)

You can specify the operator for the combination of query terms in a match (by default it's OR as you observed ). Add inside the Match
.Operator(Operator.And)

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