Facing issues with searching ES with 3 where clauses or filters

Hi , I want to query ElasticSearch with 3 filters and then take the sum of the "value" of all returned records.

My search criteria is explained below:

Include --> Fetch records matching the "valueOfColumn1" in Column1
Include --> Filter only records matching the "valueOfColumn2" in Column2
Exclude --> Filter out (remove) the records matching the "valueOfColumn3" in Column3

I have created below query but it is not working correctly and no records are being fetched. Could someone help what is incorrect in this query and let me know the correct way to do the query

client.Search(s => s.Aggregations(a => a.Sum(
SumOfValues, sm => sm.Field(f => f.Value)
)
).Query(q => q.Terms(
c => c.Name(queryKey).Field(
p => p.Column1
).Terms(valueOfColumn1)
)
&& q.Bool
(b => b
.Must(
bs => bs.Term(p => p.Column2, "valueOfColumn2")
)
.MustNot(
bs => bs.Term(p => p.Column3, "valueOfColumn3")
)
)
)
);

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