Hi
I am currently trying to write a Terms Query via the Elastic.Clients.Elasticsearch 8.1.1 .NET client.
I have to apply dynamic terms query filter for filtered categories Ids. If any category id not selected then not applied this filter on the terms query.
var response = await client.SearchAsync<EsProduct>(x => x.Index(nameof(Product).ToLowerInvariant())
.Query(q => q
.Bool(b => b
.Must(m => m
.MultiMatch(mm => mm
.Query(keywords).Fields(fields)))
.Filter(f => f
.Term(publishedQuery) // check published
.Terms(ts => ts
.Field("categories.id")
.Terms(new TermsQueryField(categoriesIds.Select(id => FieldValue.Long(id)).ToArray())))
)))
.Aggregations(a => a
.Range("price", r => r.Field(f => f.Price).Ranges(new AggregationRange[] { priceRange1, priceRange2, priceRange3 })))
.From(0).Size(100)
);
With this i can't able to get proper filtered products.
Also, i can't able to create aggregation with field type keyword. Any suggestion for this.