elastic/elasticsearch-net

Writing the Filter aggregation JSON via the aggregation descriptor seems impossible

Closed this issue · 1 comments

Elastic.Clients.Elasticsearch version:
8.18.3

Elasticsearch version:
8.18.1

.NET runtime version:
8.0.17

Operating system version:
Windws 11

Description of the problem including expected versus actual behavior:
A clear and concise description of what the bug is.

Steps to reproduce:

  1. Try to write this sample https://www.elastic.co/guide/en/elasticsearch/reference/8.18/search-aggregations-bucket-filter-aggregation.html
  2. I've tried multiple ways via the AggregationDescriptor but I cannot find a way to express just what is the sample doing

Expected behavior
A clear and concise description of what you expected to happen.
JSON generated as the sample show

Provide ConnectionSettings (if relevant):

Provide DebugInformation (if relevant):

Ok, I've found the syntax :)
fluentDescriptorDictionary.Add(notAnalyzedField.Name, c => c .Filter(facetQuery) .Aggregations(sub => sub .Add($"{notAnalyzedField.Name}-terms", d => d.Terms(ta => ta.Field(notAnalyzedField.Name).Size(facet.Size))) ) );