private static boolean isMappingExist ( RestHighLevelClient client , String index ) throws Exception { GetMappingsResponse mapping = client . indices ( ) . getMapping ( new GetMappingsRequest ( ) . indices ( index ) , RequestOptions . DEFAULT ) ; // Let's get the default mapping if ( mapping . mappings ( ) . isEmpty ( ) ) { return false ; } MappingMetaData doc = mapping . mappings ( ) . values ( ) . iterator ( ) . next ( ) ; return ! doc . getSourceAsMap ( ) . isEmpty ( ) ; }
Check if an index already exist