Open niemyjski opened 2 weeks ago
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:
Sorting with the new client is insanely verbose and tedious, to the point I don't even want to convert the tests we have...
// Previous Client.Search<MyType>(d => d.Index(index).Aggregations(a => a .Terms("terms_field1", t => t .Field("field1.keyword") .Order(o => o.Descending("cardinality_field4")))); // New await Client.SearchAsync<MyType>(d => d.Index(index).Aggregations(a => a .Add("terms_field1", a1 => a1 .Terms(t => t.Field("field1.keyword").Order(new List<KeyValuePair<Field, SortOrder>> { new ("cardinality_field4", SortOrder.Desc) })))));
// Previous if (termsAggregation != null && (child.Prefix == "-" || child.Prefix == "+")) { if (termsAggregation.Order == null) termsAggregation.Order = new List<TermsOrder>(); termsAggregation.Order.Add(new TermsOrder { Key = ((IAggregation)aggregation).Name, Order = child.Prefix == "-" ? SortOrder.Descending : SortOrder.Ascending }); } // New if (termsAggregation != null && child.Prefix is "-" or "+") { termsAggregation.Order ??= new List<KeyValuePair<Field, SortOrder>>(); termsAggregation.Order.Add(new KeyValuePair<Field, SortOrder>(aggregation.Name, child.Prefix == "-" ? SortOrder.Desc : SortOrder.Asc)); }
await Client.SearchAsync<MyType>(d => d.Index(index).Sort(s => s .Field(f => f.Field(new Field("field3")).Ascending().UnmappedType(FieldType.GeoPoint)) .Field(f => f.Field(new Field("field1.keyword")).Descending().UnmappedType(FieldType.Keyword)) .Field(f => f.Field(new Field("field2.sort")).Descending().UnmappedType(FieldType.Keyword)) .Field(f => f.Field(new Field("field3")).Descending().UnmappedType(FieldType.GeoPoint)) .Field(f => f.Field(new Field("field4")).Ascending().UnmappedType(FieldType.Long)) .Field(f => f.Field(new Field("field5")).Ascending().UnmappedType(FieldType.Date)) .Field(f => f.Field(new Field("field3")).Ascending().UnmappedType(FieldType.GeoPoint)) ));
Expected behavior
Sorting should be a very common operation and easy todo.
Reference: https://github.com/FoundatioFx/Foundatio.Parsers/pull/84
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:
Sorting with the new client is insanely verbose and tedious, to the point I don't even want to convert the tests we have...
Example 1
Example 2
Example 3 (I don't even want to think about converting)
Expected behavior
Sorting should be a very common operation and easy todo.
Reference: https://github.com/FoundatioFx/Foundatio.Parsers/pull/84