Skip to content

Commit 8a00565

Browse files
committed
delete old index - start new
1 parent 0dc49fb commit 8a00565

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.nais/test/klass-api-search.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spec:
4646
- application: klass-mail
4747
openSearch:
4848
access: readwrite
49-
instance: klass-search
49+
instance: klass-search-new
5050

5151
prometheus:
5252
enabled: true

klass-api/src/main/java/no/ssb/klass/api/services/IndexServiceImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ public void createIndexWithStemmingAnalyzer() {
8888
var indexOps = elasticsearchOperations.indexOps(getIndexCoordinates());
8989

9090
if (indexOps.exists()) {
91-
log.info("Index '{}' already exists — skipping creation.", elasticsearchIndex);
92-
return;
91+
log.info("Index '{}' exists — deletes index.", elasticsearchIndex);
92+
boolean deleted = indexOps.delete();
93+
if (!deleted) {
94+
log.warn("Failed to delete existing index '{}'. Aborting recreation.", elasticsearchIndex);
95+
return;
96+
}
9397
}
9498

9599
Map<String, Object> settings =

0 commit comments

Comments
 (0)