我正在尝试使用NEST API将\ bulk插入数据插入Elastic。
有人可以使用NEST为我提供示例吗?
谢谢, 萨米尔
答案 0 :(得分:1)
NEST documantation包含如何执行此操作的示例:
<script>
for(i=0;i<total;i++){
document.write('<table class="border game" name="game">');
document.write('<tr>');
if(gameType == "A" || gameType == "F"){
document.write('<td name="series" class="txt12 border-bottom" colspan="5"></td>');
document.write('</tr><tr>');
}
if(gameType == "D" || gameType == "L" || gameType == "W"){
document.write('<td name="series" class="txt12" colspan="5"></td>');
document.write('</tr><tr>');
document.write('<td name="record" class="txt12 border-bottom" colspan="5"></td>');
document.write('</tr><tr>');
}
document.write('<td name="awayTeam" class="txt12"></td>');
document.write('<td name="awayScore" class="txt12 runs"></td>');
document.write('<td name="runners" class="txt12" style="width:30px;text-align:center;"></td>');
document.write('<td name="status" colspan="2" class="txt12" style="width:65px;text-align:right;"></td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td name="homeTeam" class="txt12"></td>');
document.write('<td name="homeScore" class="txt12 runs"></td>');
document.write('<td name="inning" class="txt12" style="width:30px;text-align:center;"></td>');
document.write('<td name="outs" class="txt12" style="width:50px;text-align:center;"></td>');
document.write('<td name="gd" class="txt12" style="width:15px;text-align:center;"></td>');
document.write('</tr>');
document.write('</table>');
document.write("<div style='height:2px'><img src='trans.gif'></div>");
}
</script>
此外,您可以使用非常有用的var descriptor = new BulkDescriptor();
foreach (var i in Enumerable.Range(0, 1000))
{
descriptor.Index<ElasticSearchProject>(op => op
.Document(new ElasticSearchProject {Id = i})
);
}
var result = client.Bulk(descriptor);
IndexMany
祝你好运。