简体   繁体   中英

Create a lambda expression for a Query DSL with AND operator in Nest C# (Elastic search)

I have a query DSL

{"query":
{
  "match" : {
    "_all" : {
        "query" : "elastic search document",
        "operator" : "and"
     }
  }
 }
}

Converted it to a lambda expression, but no idea where to give the operator AND in the query.

 var queryResult = this.client.Search<dynamic>(d =>
             d.AllIndices()
             .AllTypes().Query(q => q.Match(m=>m.Query(queryTerm))));

You can find it on MatchQueryDescriptor<T> (the m parameter in the lambda passed to Match() )

var queryResult = client.Search<dynamic>(d => d
    .AllIndices()
    .AllTypes()
    .Query(q => q
        .Match(m => m
            .Query(queryTerm)
            .Operator(Operator.And)
        )
    )
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM