【发布时间】:2021-01-09 16:14:20
【问题描述】:
我正在尝试将超过 7000 条记录索引到 elasticsearch。我将根据它的长度从 JSonarray 中挑选所有这些记录,我将遍历数组,我将使用 Indexrequest API 将记录一一索引到 elasticsearch 中。由于我是 Elastisearch 的新手,我想确认这是正确的方法。我在下面给出了我的代码。
for (int i = 0; i < odsData.size(); i++) {
IndexRequest request = new IndexRequest(ConstantsHelper.INDEX_NAME + strDate);
request.id();
String jsonString = odsData.get(i).toString();
request.source(jsonString, XContentType.JSON);
IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT);
}
这是一个正确的方法吗?我还想检查数组中的记录数和索引完成后 Elasticsearch 中索引的记录数是否匹配?
【问题讨论】:
标签: java spring-boot elasticsearch elasticsearch-java-api