Skip to content

Commit

Permalink
feat(clients): add helper to check if an index exists (generated)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
3 people committed Sep 4, 2024
1 parent 75fbc33 commit aa8b824
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions algoliasearch/src/main/java/com/algolia/api/SearchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6743,4 +6743,16 @@ public Duration getSecuredApiKeyRemainingValidity(@Nonnull String securedApiKey)

return Duration.ofSeconds(timeStamp - Instant.now().getEpochSecond());
}

public boolean indexExists(String indexName) {
try {
getSettings(indexName);
} catch (AlgoliaApiException e) {
if (e.getStatusCode() == 404) {
return false;
}
throw e;
}
return true;
}
}

0 comments on commit aa8b824

Please sign in to comment.