use of org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest in project elasticsearch by elastic.
the class RestTypesExistsAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
TypesExistsRequest typesExistsRequest = new TypesExistsRequest(Strings.splitStringByCommaToArray(request.param("index")), Strings.splitStringByCommaToArray(request.param("type")));
typesExistsRequest.local(request.paramAsBoolean("local", typesExistsRequest.local()));
typesExistsRequest.indicesOptions(IndicesOptions.fromRequest(request, typesExistsRequest.indicesOptions()));
return channel -> client.admin().indices().typesExists(typesExistsRequest, new RestResponseListener<TypesExistsResponse>(channel) {
@Override
public RestResponse buildResponse(TypesExistsResponse response) throws Exception {
if (response.isExists()) {
return new BytesRestResponse(OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY);
} else {
return new BytesRestResponse(NOT_FOUND, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY);
}
}
});
}
use of org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest in project uavstack by uavorg.
the class ESClient method existType.
/**
* existType
*
* @param index
* @param type
* @return
*/
public boolean existType(String index, String type) {
TypesExistsRequest request = new TypesExistsRequest(new String[] { index }, type);
TypesExistsResponse resp = client.admin().indices().typesExists(request).actionGet();
if (resp.isExists()) {
return true;
}
return false;
}
use of org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest in project alien4cloud by alien4cloud.
the class EsDaoCrudTest method assertTypeExists.
private void assertTypeExists(String indexName, String typeToCheck, boolean expected) throws InterruptedException, ExecutionException, JsonGenerationException, JsonMappingException, IntrospectionException, IOException {
final ActionFuture<TypesExistsResponse> typeExistsFuture = nodeClient.admin().indices().typesExists(new TypesExistsRequest(new String[] { indexName }, typeToCheck));
final TypesExistsResponse response = typeExistsFuture.get();
assertEquals(expected, response.isExists());
}
Aggregations