Get raw query from NEST client

前端 未结 8 722
太阳男子
太阳男子 2021-01-30 08:33

Is it possible to get the raw search query from the NEST client?

var result = client.Search(s => s
             


        
8条回答
  •  故里飘歌
    2021-01-30 09:04

    You can get raw query json from RequestInformation:

    var rawQuery = Encoding.UTF8.GetString(result.RequestInformation.Request);
    

    Or enable trace on your ConnectionSettings object, so NEST will print every request to trace output

    var connectionSettings = new ConnectionSettings(new Uri(elasticsearchUrl));
    connectionSettings.EnableTrace(true);
    var client = new ElasticClient(connectionSettings); 
    

    NEST 7.x

    Enable debug mode when creating settings for a client:

    var settings = new ConnectionSettings(connectionPool)
        .DefaultIndex("index_name")
        .EnableDebugMode()
    var client = new ElasticClient(settings); 
    

    then your response.DebugInformation will contain information about request sent to elasticsearch and response from elasticsearch. Docs.

提交回复
热议问题