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) { for (String entityType : entities) {
if (Boolean.FALSE.equals(jobData.getRecreateIndex())) { if (Boolean.FALSE.equals(jobData.getRecreateIndex())) {
LOG.debug("RecreateIndex is false. Skipping index recreation for '{}'.", entityType); LOG.debug("RecreateIndex is false. Skipping index recreation for '{}'.", entityType);
return; return;
} }
IndexMapping indexType = searchRepository.getIndexMapping(entityType);
// 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);
if (indexType == null) { if (indexType == null) {
LOG.warn( LOG.warn(
"No index mapping found for entityType '{}'. Skipping index recreation.", "No index mapping found for entityType '{}'. Skipping index recreation.", entityType);
correctedEntityType); continue;
return;
} }
searchRepository.deleteIndex(indexType); searchRepository.deleteIndex(indexType);
searchRepository.createIndex(indexType); searchRepository.createIndex(indexType);
LOG.info("Recreated index for entityType '{}'.", correctedEntityType); LOG.info("Recreated index for entityType '{}'.", entityType);
} }
} }