I have My Elastic Query working well, I have aggregations and I have it sorting on a particular field, but if the user wants to say sort it on price, how can i dynamically change the sort field, without putting a switch statement around the entire query to select a different field.
my current query:
.Sort(ss => ss
.Field(f => f
.Field(ff => ff.DispatchTimeInDays)
.Order(Nest.SortOrder.Ascending)
)
)
You can do this in the
Fieldlambda expressionYou may want to factor this out into a method so that the fluent method call doesn't grow unwieldy