【问题标题】:Why is the data not stored in elasticsearch?为什么数据没有存储在elasticsearch中?
【发布时间】:2019-02-02 13:05:32
【问题描述】:

我在 elasticsearch 中使用 NEST 来处理请求。将数据保存到elasticsearch时出现错误。

请求:PUT: /strategy/30772377 {"id": 1, "name": "strategy1"}

保存时,NEST 返回错误。

我的代码:

var settings = new ConnectionSettings(new StaticConnectionPool(uri));

var client = new ElasticClient(settings);

var response = await client.IndexAsync(
                    model,
                    x => x.Type(indexType).Index(indexName),
                    cancellationToken).ConfigureAwait(false);

错误:

NEST.Response.DebugInformation:

从对 PUT 的不成功的低级别调用构建的无效 NEST 响应: /strategy/30772377

此 API 调用的审核跟踪: - [1] 错误响应:节点:http://localhost:9200/ 接受:00:00:51.9406716 - [2] CancellationRequested:花费:00:00:00

OriginalException: Elasticsearch.Net.ElasticsearchClientException: The 请求被中止:请求被取消。呼叫:状态代码 未知来自:PUT /strategy/30772377 --->

System.Net.WebException:请求被中止:请求被 取消。在 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 在 System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean 需要同步) --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)在 Elasticsearch.Net.HttpWebRequestConnection。

d__5`1.MoveNext() --- 内部异常堆栈结束 追踪---

请求:{"id": 1, "name": "strategy1"}

回复:

【问题讨论】:

    标签: c# elasticsearch nest


    【解决方案1】:

    调试信息中的审计跟踪表明该请求最终被使用CancellationToken 取消。在此之前的审计事件表明来自 Elasticsearch 的错误响应;如果请求有问题,response.ServerError 将包含来自 Elasticsearch 的错误。

    【讨论】:

    • ServerError 为空。服务器错误: 。结果:错误。 ApiCall:对 PUT 的低级调用不成功:/strategy/1
    • 你能显示来自 Elasticsearch 的整个 JSON 响应吗?您可以使用 Fiddler 之类的东西来捕获它:elastic.co/guide/en/elasticsearch/client/net-api/current/… 另外,您能否展示一个完整的、可重现的示例来演示您所看到的问题?您可以编辑问题以添加这些,例如model 是什么,indexTypeindexName,等等。
    • 感谢您的帮助。很可能问题不在于 Elasticsearch,而在于硬盘。今天系统管理员换盘,明天查。
    • 问题出在硬盘上。更换后,一切正常,没有错误。谢谢你的回答。
    猜你喜欢
    • 2019-11-06
    • 1970-01-01
    • 2017-10-17
    • 1970-01-01
    • 1970-01-01
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多