Skip to content

Commit

Permalink
Fixes for reindex
Browse files Browse the repository at this point in the history
  • Loading branch information
haarli committed Nov 27, 2023
1 parent c67e857 commit 52cbe1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void updateIndexBatch(List<?> objectList)
try {
LOGGER.info("+++ index request " + indexName + " " + getId(obj));
final IndexOperation indexOperation;
if (obj instanceof ResourceLastModified) {
if (obj instanceof ResourceLastModified && ((ResourceLastModified) obj).getModified() != null) {
long timestamp = ((ResourceLastModified) obj).getModified().getTimeInMillis();
indexOperation = getIndexOperation(getId(obj), toJson(obj, dataType, indexName), getParent(obj), dataType, timestamp);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ public static void run(List<?> list, String index) throws IOException, SearchInd
List<Item> items = (List<Item>) list.stream().filter(o -> o instanceof Item).collect(Collectors.toList());
final BulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder();

boolean fieldsFound = false;
for (final Item item : items) {
CollectionFields fields = retrieveCollectionFields(item, index);
if (fields != null) {
fieldsFound = true;
final ObjectNode json = fields.toJsonNode();
bulkRequestBuilder.operations(BulkOperation
.of(bo -> bo.update(ur -> ur.index(ElasticIndices.items.name()).id(item.getId().toString()).action(act -> act.doc(json)))));

}
}


if (items.size() > 0) {
if (fieldsFound) {
final BulkRequest bulkRequest = bulkRequestBuilder.build();
BulkResponse bulkResponse = ElasticService.getClient().bulk(bulkRequest);

Expand Down

0 comments on commit 52cbe1a

Please sign in to comment.