Open ghendo opened 2 years ago
That looks like it should be right. Is it not returning the correct results for you?
I wanted the results sorted highest date first to lowest date
You should be able to get that by adding a $sort
stage after the $search
stage.
I am trying to implement the following query but having trouble This is the query
{ "$search" : { "compound":{ "filter" : { "compound":{ "should" : [ { "autocomplete" : { "query" : ["john"], "path" : "site.name"} }, { "autocomplete" : { "query" : ["john"], "path" : "site.client.onsiteClientName" } }, { "autocomplete" : { "query" : ["john"], "path" : "subContractor.companyName" } }, { "autocomplete" : { "query" : ["john"], "path" : "supervisor.givenName"} } ], "minimumShouldMatch" : 1 }}, "must" : [ { "near" : { "path" : "startTime", "origin" : ISODate("1000-12-31T23:59:59.999Z"), "pivot" : 1 } }], }} }
This is what I tried
var pipelineData = pipeline .Search(SearchBuilders<T>.Search.Compound() .Filter(SearchBuilders<T>.Search.Compound() .Should(searches).MinimumShouldMatch(minShouldMatch) .Must(nearFilter)), null, "JobAutoV2")
where searches is array of autocompletes
and nearfilter is var nearFilter = new SearchDefinitionBuilder().Near(sortField, new DateTime(1100,12,31), 60000);
but I feel this is wrong