【发布时间】:2018-04-07 20:35:17
【问题描述】:
我想使用 NEST 或 Elasticsearch.Net API 批量索引 json 记录以进行弹性搜索
我的 json 数据是:
{"index":{"_index":"abc","_type":"abc","_id":1}},{"Name":"ApplicationFrameHost","CPU":1.25,"Company":null,"Product":null,"Path":null},{"index":{"_index":"abc","_type":"abc","_id":2}},{"Name":"Calculator","CPU":0.5,"Company":null,"Product":null,"Path":null},{"index":{"_index":"abc","_type":"abc","_id":3}},{"Name":"chrome","CPU":142.9375,"Company":null,"Product":null,"Path":null},{"index":{"_index":"abc","_type":"abc","_id":4}},{"Name":"chrome","CPU":3336.34375,"Company":null,"Product":null,"Path":null},{"index":{"_index":"abc","_type":"abc","_id":5}},{"Name":"chrome","CPU":7.1875,"Company":null,"Product":null,"Path":null}\n\n
我的代码:
var connectionSettings = new ConnectionSettings(new
Uri("http://localhost:9200/"));
var client2 = new ElasticClient(connectionSettings);
var jsonPostData = new PostData<object>(myJson);
var bulkRequestParameters = new BulkRequestParameters
{
};
Func<BulkRequestParameters, BulkRequestParameters> convert = delegate
(BulkRequestParameters s)
{
s.ErrorTrace(true);
return s.Refresh(Refresh.True);
};
var response = client2.LowLevel.Bulk<VoidResponse>("abc", "abc",
jsonPostData, convert);
在响应弹性返回成功没有错误但仍然弹性上没有数据?
来自 elastic 的调试信息:POST 上的成功低级调用:/abc/abc/_bulk?error_trace=true&refresh=true
如果有人能提供任何线索我在这里做错了什么会非常有帮助?
【问题讨论】:
标签: c# elasticsearch