elasticsearch-net
elasticsearch-net copied to clipboard
Consolidate usage of `FluentDescriptorDictionary`
Elastic.Clients.Elasticsearch version: 8.15.6
Elasticsearch version: 8.15.1
.NET runtime version: 8.x
Operating system version: Any
Description of the problem including expected versus actual behavior:
In the past we built up queries and then assigned them to the descriptor. This is useful in our scenario but also in several apps when you want to conditionally build up queries based on method parameters over various control statements.
var result = await processor.BuildAggregationsAsync($"date:(field5~{interval})");
await Client.SearchAsync<MyType>(d => d.Index(index).Aggregations(result));
// ElasticQueryParserTests.cs(712, 94): [CS0201] Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
var result = await processor.BuildQueryAsync("field1:value1", new ElasticQueryVisitorContext().UseSearchMode());
await Client.SearchAsync<MyType>(d => d.Index(index).Query(_ => result));
// ElasticQueryParserTests.cs(717, 29): [CS0201] Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Expected behavior
I should be able to apply built up query and aggregation descriptors to the fluent api
Reference: https://github.com/FoundatioFx/Foundatio.Parsers/pull/84