I am new to Nest, and I most likely do not create my request, as it seems to me. My question is more about how to teach a person how to fish, and not give me fish. However, as an example, I will take advantage of my current problem.
I have several documents in an ElasticSearch of type Series . I will disable it below without attributes and public modifiers only with information related to the request:
class Series { string Id {get; set;} DateTime StartDate {get; set;} DateTime EndDate {get; set;} HashSet<Role> ReleasableTo {get; set;} }
They are all beautiful and dandy. I can Get() a Series object without problems. The problem I am facing is trying to figure out how Nest formats my request. My immediate goal is to find the latest Series , which can be divided into Role.Visitor . I installed the Nest request as follows:
ISearchResponse<Series> response = client .Search<Series>(r => r.Filter(f => f.Term<Role>(t=>t.ReleasableTo.First(), Role.Visitor)) .SortDescending(ser => ser.EndDate).Size(1));
In my opinion, this should produce a query that filters the series, so only those that are ReleasableTo my Role.Visitor are taken into account, reverse sorts by end date and limit the results to one returned. That would be exactly what I want. In the several thousand records that I have for Series, about 90% correspond to this profile. Unfortunately, the query returns 0 results. No mistake, just no results. I donβt know if I am using the API incorrectly, if Nest creates a query structure that does not make sense, or I just donβt know ElasticSearch enough. When I delete the Filter clause, I get the result, but I am not guaranteed that everyone is allowed to see it.
How to view the JSON that Nest ElasticSearch produces and sends?
c # elasticsearch nest
Berin loritsch
source share