How to know if index already exist in elastic server

how do I know at runtime if index already created or not in elastic server?
I need to automate mass index in batch file for missing data in db

so logic would be like
if(!indexPresent){
searchSession.massIndexer().startAndWait();
}

how I find indexPresent or not in elastic server

You can validate the presence and mapping of an index with a SchemaManager.

It’ll be a bit ugly, but something like this should work:

SearchMapping searchMapping = Search.mapping(entityManagerFactory); 
SearchScope<?> scope = mapping.scope(Object.class); 
SearchSchemaManager schemaManager = scope.schemaManager(); 
try {
    schemaManager.validate();
    // The index exists and has the correct mapping
    // We probably don't need reindexing
    return;
}
catch (SearchException ignored) {
    // At least one index is absent or invalid.
    // We'll reindex, see below.
}
// Create missing indexes, drop and create existing indexes (purging data).
schemaManager.dropAndCreate();
// Populate indexes.
scope.massIndexer().startAndWait();