I have this elasticsearch query, that works perfect in a raw format and I am having trouble turning it into a C# NEST clause.
This is the raw query:
{
"query":{
"constant_score":{
"filter":{
"bool":{
"must":{
"term":{
"ingredients":"baking"
}
},
"must":{
"term":{
"ingredients":"soda"
}
}
}
}
}
}
}
And this is what I thought would work in C# NEST:
public List<Recipe> FindByMultipleValues(string field, string[] values) {
List<string> vals = values.ToList();
return client.Search<Recipe>(s => s
.Query(q => q
.Bool(fq => fq
.Filter(f => f
.Term(rec => rec.Ingredients, vals)
)
)
)
).Documents.ToList();
}
The user can send an array of x values, which means that for each value there must be a:
"must":{
"term":{
"ingredients":"soda"
}
}
mustclause of aboolquery is an array; I would suspect that the secondmustclause property will end up overwriting the first. What version of NEST are you using?