我一直在嘗試使用批量插入功能,但每次使用它都會顯示一些映射錯誤。批量插入函數聲明已經從嵌套1.x更改爲嵌套5.x,因爲在5.x嵌套文檔中我沒有找到.bulk()函數。請推薦elasticsearch的批量插入嵌套5.x
代碼BULK INSERT:
public void bulkInsert(List<BaseData> recordList, List<String> listOfIndexName)
{
BulkDescriptor descriptor = new BulkDescriptor();
descriptor.Index<BaseData>(op => op
.Document(recordList[j])
.Index(listOfIndexName[j])
);
}
var result = clientConnection.Bulk(descriptor);
}
我,我傳遞數據的列表看起來是這樣的:
[ElasticsearchType(IdProperty = "number")]
class TicketData : BaseData
{
//[ElasticProperty(Index = FieldIndexOption.NotAnalyzed, Store = true)]
[Date(Name = "sys_updated_on", Store = true)]
public DateTimeOffset sys_updated_on { get; set; }
[Text(Name = "number", Store = true)]
public override string number { get; set; }
[Text(Name = "incident_state", Store = true)]
public string incident_state { get; set; }
[Text(Name = "location", Store = true)]
public string location { get; set; }
[Text(Name = "assigned_to", Store = true)]
public string assigned_to { get; set; }
[Text(Name = "u_knowledge_id", Store = true)]
public string u_knowledge_id { get; set; }
[Text(Name = "u_knowledge_id.u_process_role", Store = true)]
public string u_knowledge_id_u_process_role { get; set; }
}
而錯誤是? –
該解決方案可能對您有所幫助。 http://stackoverflow.com/questions/22017858/how-to-bulk-insert-json-using-nest-elasticsearch 或者你可以參考這個,從這個鏈接你可以得到更多關於批量插入的基本想法謝謝! –
您看起來像是在示例中缺少代碼什麼是'描述符'?你能編輯你的問題來添加那個細節嗎?另外,映射錯誤是什麼? Elasticsearch返回什麼錯誤?大容量請求json是什麼樣的? –