How do you debug your Nest queries?

前端 未结 8 1921
失恋的感觉
失恋的感觉 2021-02-05 14:02

I\'m new to Nest, and I very likely am not creating my query like I think I am. My question is more along the lines of teach a man to fish rather than give me a fish. However,

8条回答
  •  青春惊慌失措
    2021-02-05 14:31

    I like to take it a step further than bsarkar suggests and eliminate the need for a roundtrip altogether:

    var client = new ElasticClient();
    
    var seriesSearch = new SearchDescriptor();
    seriesSearch.Filter(f => f
        .Term(t => t.ReleasableTo.First(), Role.Visitor))
        .SortDescending(ser => ser.EndDate)
        .Size(1));
    
    string searchJson = Encoding.UTF8.GetString(client.Serializer.Serialize(seriesSearch));
    

    Note that your ElasticClient doesn't need any connection properties, so you have no dependency on an ES node.

提交回复
热议问题