Skip to content

Commit aa8b824

Browse files
algolia-botmillotpFluf22
committed
feat(clients): add helper to check if an index exists (generated)
algolia/api-clients-automation#3646 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent 75fbc33 commit aa8b824

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

algoliasearch/src/main/java/com/algolia/api/SearchClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6743,4 +6743,16 @@ public Duration getSecuredApiKeyRemainingValidity(@Nonnull String securedApiKey)
67436743

67446744
return Duration.ofSeconds(timeStamp - Instant.now().getEpochSecond());
67456745
}
6746+
6747+
public boolean indexExists(String indexName) {
6748+
try {
6749+
getSettings(indexName);
6750+
} catch (AlgoliaApiException e) {
6751+
if (e.getStatusCode() == 404) {
6752+
return false;
6753+
}
6754+
throw e;
6755+
}
6756+
return true;
6757+
}
67466758
}

0 commit comments

Comments
 (0)