I'm trying to delete elastic documents in bulk amount, but I get exception "java.lang.reflect.InaccessibleObjectException: Unable to make field private final transient java.net.InetSocketAddress" when elasticsearchOperations.delete(...) is executed. Here is the code, not able to figure out what is causing it. Any help is much appreciated.
private void deleteElasticDocuments(String catalogId) {
List<String> docIdList = new ArrayList<>(250);
String queryText = martServerContext.getQueryCacheInstance().getQuery(QUERY_PORTAL_GET_OBJECTS_IN_PORTAL_BY_MODEL);
MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource();
mapSqlParameterSource.addValue("cId", Integer.parseInt(catalogId));
namedParameterJdbcTemplate.query(queryText, mapSqlParameterSource, (resultSet -> {
int objectId = resultSet.getInt(O_ID);
String docId = catalogId + objectId;
docIdList.add(docId);
if (docIdList.size() == 250) {
Query query = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.idsQuery().addIds(docIdList.toArray(String[]::new)))
.build();
elasticsearchOperations.delete(query, IndexCoordinates.of("portal_idx"));
docIdList.clear();
}
// elasticsearchOperations.delete(docId, IndexCoordinates.of("portal_idx"));
}));
if (docIdList.size() < 250) {
Query query = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.idsQuery().addIds(docIdList.toArray(String[]::new)))
.build();
elasticsearchOperations.delete(query, IndexCoordinates.of("portal_idx"));
docIdList.clear();
}
}