Elasticsearch Version
7.1.1
client:
public void index(List<PromoSkuInfoEsEntry> promoSkuInfoEsEntries) throws IOException {
BulkRequest request = new BulkRequest();
List<List<PromoSkuInfoEsEntry>> lists = Lists.partition(promoSkuInfoEsEntries, 5000);
for (List<PromoSkuInfoEsEntry> list : lists) {
for (PromoSkuInfoEsEntry promoSkuInfoEsEntry : list) {
String jsonValue = objectMapper.writeValueAsString(promoSkuInfoEsEntry);
String id = PromoGenerateIdUtil.getPromoSkuESId(promoSkuInfoEsEntry);
UpdateRequest updateRequest = new UpdateRequest(xxx, id).routing(promoSkuInfoEsEntry.getSkuId());
updateRequest.doc(jsonValue, XContentType.JSON);
updateRequest.docAsUpsert(true);
request.add(updateRequest);
}
BulkResponse bulk = newPromoRestHighLevelClient.bulk(request, RequestOptions.DEFAULT);
checkBulkResponse(bulk);
}
}
client version:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.1.1</version>
</dependency>````
err log:
- Caused by: org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=version_conflict_engine_exception, reason=[1_1449437083_12352061_2020616363]: version conflict, required seqNo [69120140], primary term [1]. current document has seqNo [103022466] and primary term [1]]
- at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:491)
- at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:402)
- at org.elasticsearch.action.bulk.BulkItemResponse.fromXContent(BulkItemResponse.java:139)
- at org.elasticsearch.action.bulk.BulkResponse.fromXContent(BulkResponse.java:199)
- at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1706)
- at org.elasticsearch.client.RestHighLevelClient.lambda$performRequestAndParseEntity$8(RestHighLevelClient.java:1374)
- at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1450)
- at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1403)
- at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1373)
- at org.elasticsearch.client.RestHighLevelClient.bulk(RestHighLevelClient.java:477)
- at com.jddj.promo.search.db.es.PromoSkuOperateEs.index(PromoSkuOperateEs.java:99)