У меня есть документ mon go, который повторяется одна за другой, затем вставляется в elasti c Поиск по одной, но первая запись только вставляется в elasti c Поиск других записей, получая 400 ошибок ниже, я упомянул эту ошибку
HttpResponseProxy {HTTP / 1.1 400 Bad Request [тип контента: приложение / json; charset = UTF-8] org. apache .http.client.entity.DecompressingEntity
HttpPost request = new HttpPost("http://" + host + ":" + port + "/" + esIndexname + "/" + esTypename);
BasicDBList updateList = new BasicDBList();
int count=0;
for (DBObject document : documents) {
try {
count++;
String objectid = document.get("_id").toString();
document.removeField("_id");
String doc = document.toString();
StringEntity postingString = new StringEntity(doc);
postingString.setChunked(true);
request.addHeader("content-type", "application/json;charset=UTF-8");
request.setEntity(postingString);
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpResponse response = httpClient.execute(request);
int st = response.getStatusLine().getStatusCode();
if (st == 400) {
errorList.add(objectid);
}
else {
updateList.add(new ObjectId(objectid));
}
httpClient.close();
} catch (Exception ex) {
ex.printStackTrace();
log.error(ex);
}
}