I am taking input from a client to build up an elasticsearch query using NEST. I start out with the basics, like so:
var search = esClient.Search<MyData>(s => s
.From(pageNum * pageSize)
.Take(pageSize)
.QueryRaw(@"{""match_all"": {} }")
I then parse out the request and see if an optional sorting parameter was passed in. If it was, I create a new SearchDescriptor<MyData>()
which performs that requested sort, and I want to add it to my original search
criteria. Obviously .Search()
will actually perform an HTTP call, so it can't happen as it is today, but how can I stick a series of SearchDescriptor
calls together and then perform the search at the end?
You can build
SearchDescriptor
incrementally as under. I've used aggregations instead of facets (which are deprecated now) but I hope you get the idea.