Fix: recreate fails if we can't find one index for a given entity (#22047)

This commit is contained in:
Sriharsha Chintalapani 2025-06-30 17:38:31 -07:00 committed by GitHub
parent ccdaa8d132
commit 52a8ec0489
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -791,30 +791,21 @@ public class SearchIndexApp extends AbstractNativeApplication {
}
}
private void reCreateIndexes(Set<String> entities) throws SearchIndexException {
private void reCreateIndexes(Set<String> entities) {
for (String entityType : entities) {
if (Boolean.FALSE.equals(jobData.getRecreateIndex())) {
LOG.debug("RecreateIndex is false. Skipping index recreation for '{}'.", entityType);
return;
}
// Handle incorrect entity type name for query cost
String correctedEntityType = entityType;
if ("queryCostResult".equals(entityType)) {
LOG.warn("Found incorrect entity type 'queryCostResult', correcting to 'queryCostRecord'");
correctedEntityType = QUERY_COST_RECORD;
}
IndexMapping indexType = searchRepository.getIndexMapping(correctedEntityType);
IndexMapping indexType = searchRepository.getIndexMapping(entityType);
if (indexType == null) {
LOG.warn(
"No index mapping found for entityType '{}'. Skipping index recreation.",
correctedEntityType);
return;
"No index mapping found for entityType '{}'. Skipping index recreation.", entityType);
continue;
}
searchRepository.deleteIndex(indexType);
searchRepository.createIndex(indexType);
LOG.info("Recreated index for entityType '{}'.", correctedEntityType);
LOG.info("Recreated index for entityType '{}'.", entityType);
}
}