【发布时间】:2014-02-25 14:56:05
【问题描述】:
我正在尝试使用 Nest 将多条记录插入我的数据库。使用 IndexMany 类插入确实有效,但我还需要通过 json 字符串插入对象。
我确实查看了 github,并找到了一些如何使用 RAWclient 的示例。在代码示例下方,我插入了我的 json。
> var twitter = _jsonData;
> var result = client.Raw.BulkPost(
> new { twitter }
> , qs => qs
> //.Replication(ReplicationOptions.Async)
> .Refresh(true) );
一些附加信息:
jsondata:
tweet tweet1 = new tweet { id = "104", name = "test104", lastname = "test107" }; //ect....
List<tweet> data; //multiple tweet objects are added
string json = Newtonsoft.Json.JsonConvert.SerializeObject(data);
var twitter:
{
"twitter": "[{'name':'test104','lastname':'test107','id':'104'},{'name':'test105','lastname':'test108','id':'105'},{'name':'test106','lastname':'test109','id':'106'}]"
}
我从数据库收到的结果:
{"error":"Unexpected end-of-input: expected close marker for OBJECT (from [Source: [B@10893e4; line: 1, column: 0])\n at [Source: [B@10893e4; line: 2, column: 3]"}
有谁知道可能是什么问题?或者我在我的 json/code 中遗漏了什么?
【问题讨论】:
标签: c# json elasticsearch nest