"Invalid NEST response built from a unsuccessful () low level call on POST"
"Invalid NEST response built from a unsuccessful () low level call on POST"
以下代码大部分时间都有效,但有时会抛出异常并显示此消息:
Invalid NEST response built from a unsuccessful () low level call on POST: /queries2020-09/_search?typed_keys=true
var response = await client.SearchAsync<LogEntry>(s => s
.Query(q => q
.Bool(b => b
.Must(m => m.DateRange(r => r.Field(l => l.DateTimeUTC)
.GreaterThanOrEquals(new DateMathExpression(since))),
m => m.Term(term)
)))
.Aggregations(a => a
.Sum("total-cost", descriptor => descriptor
.Field(f => f.Cost)
.Missing(1)))
.Size(0));
if (!response.IsValid)
{
throw new Exception("Elasticsearch response error. " + response.ToString());
}
这似乎是一条在问答网站上经常弹出的非常笼统的消息。如何调试它以查看根本原因?
使用 NEST 7.6.1.
写出 debug information 可能比 .ToString()
更好
if (!response.IsValid)
{
throw new Exception("Elasticsearch response error. " + response.DebugInformation);
}
调试信息包括审计跟踪和有关 error/exception 的详细信息(如果有的话)。这是一种以人类可读的形式收集 IResponse
上可用的相关信息的便捷方法。
如果始终检查响应的有效性并抛出异常,您可能需要在 ConnectionSettings
上设置 ThrowExceptions()
以在发生错误时抛出异常。
以下代码大部分时间都有效,但有时会抛出异常并显示此消息:
Invalid NEST response built from a unsuccessful () low level call on POST: /queries2020-09/_search?typed_keys=true
var response = await client.SearchAsync<LogEntry>(s => s
.Query(q => q
.Bool(b => b
.Must(m => m.DateRange(r => r.Field(l => l.DateTimeUTC)
.GreaterThanOrEquals(new DateMathExpression(since))),
m => m.Term(term)
)))
.Aggregations(a => a
.Sum("total-cost", descriptor => descriptor
.Field(f => f.Cost)
.Missing(1)))
.Size(0));
if (!response.IsValid)
{
throw new Exception("Elasticsearch response error. " + response.ToString());
}
这似乎是一条在问答网站上经常弹出的非常笼统的消息。如何调试它以查看根本原因?
使用 NEST 7.6.1.
写出 debug information 可能比 .ToString()
if (!response.IsValid)
{
throw new Exception("Elasticsearch response error. " + response.DebugInformation);
}
调试信息包括审计跟踪和有关 error/exception 的详细信息(如果有的话)。这是一种以人类可读的形式收集 IResponse
上可用的相关信息的便捷方法。
如果始终检查响应的有效性并抛出异常,您可能需要在 ConnectionSettings
上设置 ThrowExceptions()
以在发生错误时抛出异常。