How do you debug your Nest queries?

前端 未结 8 1927
失恋的感觉
失恋的感觉 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:26

    Elasticsearch.Net and NEST: the .NET clients [7.x]

    ref: https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/debug-information.html`

    1. Enable DisableDirectStreaming in ES Global setting like following.

    ref code

    Var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
    
    var settings = new ConnectionSettings(connectionPool)
        .DisableDirectStreaming(true); 
    
    var client = new ElasticClient(settings);
    

    2.) var response = client.Search(s =>....)

    3.)

    var jsonOutput = System.Text.Encoding.UTF8.GetString(
                result.ApiCall.RequestBodyInBytes);
    

    Above can be achieved on a per request basis with following.

    var response = client.Search(s => s
        .RequestConfiguration(r => r
            .DisableDirectStreaming() 
        )
        .Query(q => q
            .MatchAll()
        )
    );
    

提交回复
热议问题