Nest Elasticsearch, combining bool query of Must and Should Nest Elasticsearch, combining bool query of Must and Should elasticsearch elasticsearch

Nest Elasticsearch, combining bool query of Must and Should


I could find where was my mistake!I used Querycontainer for format in the same command as what I used for Year and then used Must in my query. Here is the changed part of the code:

 // For FORMAT QueryContainer qF=null; foreach (var format in txtDocs) {     qF |= new TermQuery()     {          Field = "format",          Value = format      };  }//MY QUERYvar searchResults = client.Search<Document>(s => s     .Fields(        f => f.Title,         f => f.Format,         f => f.Year,         f => f.DateCreated,         f => f.Id,         f => f.Path,         f => f.Size,         f => f.Firstwords)    .Index(defaultIndex)    .From(0)    .Size(100)    .Query(q => q       .Bool(b => b.MustNot(qYear)       .Must(qF)       .Should(qc.ToArray())     ));