@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( indexName ) .pathComponent( Paths._SETTINGS ); return builder.build(); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( indexName ) .pathComponent( Paths._SETTINGS ); return builder.build(); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( indexName ) .pathComponent( Paths._MAPPING ); return builder.build(); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( indexName ) .pathComponent( Paths._MAPPING ); return builder.build(); }
private String getVersion(ElasticsearchClient client) { ElasticsearchRequest request = ElasticsearchRequest.get().build(); ElasticsearchResponse response = null; try { response = client.submit( request ).join(); if ( !ElasticsearchClientUtils.isSuccessCode( response.getStatusCode() ) ) { throw log.elasticsearchResponseIndicatesFailure(); } return VERSION_ACCESSOR.get( response.getBody() ).get(); } catch (RuntimeException e) { throw log.elasticsearchRequestFailed( request, response, e ); } } }
private String getVersion(ElasticsearchClient client) { ElasticsearchRequest request = ElasticsearchRequest.get().build(); ElasticsearchResponse response = null; try { response = client.submit( request ).join(); if ( !ElasticsearchClientUtils.isSuccessCode( response.getStatusCode() ) ) { throw log.elasticsearchResponseIndicatesFailure(); } return VERSION_ACCESSOR.get( response.getBody() ).get(); } catch (RuntimeException e) { throw log.elasticsearchRequestFailed( request, response, e ); } } }
private String getSettings(URLEncodedString indexName, String path) { ElasticsearchResponse response = performRequest( ElasticsearchRequest.get() .pathComponent( indexName ).pathComponent( Paths._SETTINGS ) .build() ); JsonObject result = response.getBody(); JsonElement index = result.get( indexName.original ); if ( index == null ) { return new JsonObject().toString(); } JsonElement settings = index.getAsJsonObject().get( "settings" ); for ( String property : path.split( "\\." ) ) { if ( settings == null ) { break; } settings = settings.getAsJsonObject().get( property ); } if ( settings == null ) { return new JsonObject().toString(); } return settings.toString(); }
private String getMapping(URLEncodedString indexName, URLEncodedString mappingName) { /* * Elasticsearch 5.5+ triggers a 404 error when mappings are missing, * while 5.4 and below just return an empty mapping. * In our case, an empty mapping is fine, so we'll just ignore 404. */ ElasticsearchResponse response = performRequestIgnore404( ElasticsearchRequest.get() .pathComponent( indexName ).pathComponent( Paths._MAPPING ).pathComponent( mappingName ) .build() ); JsonObject result = response.getBody(); JsonElement index = result.get( indexName.original ); if ( index == null ) { return new JsonObject().toString(); } JsonElement mappings = index.getAsJsonObject().get( "mappings" ); if ( mappings == null ) { return new JsonObject().toString(); } JsonElement mapping = mappings.getAsJsonObject().get( mappingName.original ); if ( mapping == null ) { return new JsonObject().toString(); } return mapping.toString(); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( indexName ) .pathComponent( typeName ) .pathComponent( id ) .pathComponent( Paths._EXPLAIN ) .body( payload ); return builder.build(); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( indexName ) .pathComponent( typeName ) .pathComponent( id ) .pathComponent( Paths._EXPLAIN ) .body( payload ); return builder.build(); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( Paths._CLUSTER ) .pathComponent( Paths.HEALTH ) .pathComponent( indexName ) .param( "wait_for_status", requiredStatus.getElasticsearchString() ) .param( "timeout", timeout ); return builder.build(); }
protected JsonElement getDocumentField(URLEncodedString indexName, URLEncodedString typeName, URLEncodedString id, String fieldName) { ElasticsearchResponse response = performRequest( ElasticsearchRequest.get() .pathComponent( indexName ).pathComponent( typeName ).pathComponent( id ) .param( "stored_fields", fieldName ) .build() ); JsonObject result = response.getBody(); return result.get( "fields" ).getAsJsonObject().get( fieldName ); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .pathComponent( Paths._CLUSTER ) .pathComponent( Paths.HEALTH ) .pathComponent( indexName ) .param( "wait_for_status", requiredStatus.getElasticsearchString() ) .param( "timeout", timeout ); return builder.build(); }
private JsonObject getDocumentSource(URLEncodedString indexName, URLEncodedString typeName, URLEncodedString id) { ElasticsearchResponse response = performRequest( ElasticsearchRequest.get() .pathComponent( indexName ).pathComponent( typeName ).pathComponent( id ) .build() ); JsonObject result = response.getBody(); return result.get( "_source" ).getAsJsonObject(); }
@Override protected ElasticsearchRequest buildRequest() { ElasticsearchRequest.Builder builder = ElasticsearchRequest.get() .multiValuedPathComponent( indexNames ); if ( !typeNames.isEmpty() ) { builder.multiValuedPathComponent( typeNames ); } builder.pathComponent( Paths._COUNT ); if ( query != null ) { builder.body( query ); } return builder.build(); }
private void waitForRequiredIndexStatus(final URLEncodedString indexName) { performRequest( ElasticsearchRequest.get() .pathComponent( Paths._CLUSTER ).pathComponent( Paths.HEALTH ).pathComponent( indexName ) /* * We only wait for YELLOW: it's perfectly fine, and some tests actually expect * the indexes to never reach a green status */ .param( "wait_for_status", ElasticsearchIndexStatus.YELLOW.getElasticsearchString() ) .param( "timeout", ElasticsearchEnvironment.Defaults.INDEX_MANAGEMENT_WAIT_TIMEOUT + "ms" ) .build() ); }