本文整理汇总了Java中org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest类的典型用法代码示例。如果您正苦于以下问题:Java TypesExistsRequest类的具体用法?Java TypesExistsRequest怎么用?Java TypesExistsRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypesExistsRequest类属于org.elasticsearch.action.admin.indices.exists.types包,在下文中一共展示了TypesExistsRequest类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareRequest
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
@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);
}
}
});
}
示例2: handleRequest
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
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()));
client.admin().indices().typesExists(typesExistsRequest, new RestResponseListener<TypesExistsResponse>(channel) {
@Override
public RestResponse buildResponse(TypesExistsResponse response) throws Exception {
if (response.isExists()) {
return new BytesRestResponse(OK);
} else {
return new BytesRestResponse(NOT_FOUND);
}
}
});
}
示例3: existType
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
/**
* 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;
}
示例4: initIndex
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
/**
* 初始化索引
*
* @throws Exception
*/
private static void initIndex() throws Exception {
String indice = esprop.getIndice();
IndicesAdminClient c = client.admin().indices();
//创建一个空的
boolean a = c.prepareExists(indice).get().isExists();
LOGGER.info("index {} isExists {}",indice, a);
if (!c.prepareExists(indice).get().isExists()) {
CreateIndexResponse createIndexResponse =c.prepareCreate(indice).get();
LOGGER.info("create index {}", createIndexResponse);
}
for (IndexType type : IndexType.values()) {
TypesExistsResponse typesExistsResponse = c.typesExists(new TypesExistsRequest(new String[]{indice}, type.getDataName())).get();
if (typesExistsResponse.isExists()) {
continue;
}
String esMapper = type.getMapper();
InputStream in = EsClientManager.class.getResourceAsStream(esMapper);
String mappingStr = IOUtils.toString(in).trim();
IOUtils.closeQuietly(in);
c.preparePutMapping(indice).setType(type.getDataName()).setSource(mappingStr).get();
}
}
示例5: isTypeExist
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
/**
* check whether type "type" under index "index" is exist
* must ensure "index" exists!
* @param index
* @param type
* @return
*/
public boolean isTypeExist(String index, String type) {
TypesExistsResponse response = client
.admin()
.indices()
.typesExists(new TypesExistsRequest(new String[]{index}, type))
.actionGet();
return response.isExists();
}
示例6: typeExists
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
/**
* Checks if a given data type exists. It is a given that the index exists
* <p/>
* @param client
* @param typeName
* @return
*/
private boolean typeExists(Client client, String indexName, String typeName) {
AdminClient admin = client.admin();
IndicesAdminClient indices = admin.indices();
ActionFuture<TypesExistsResponse> action = indices.typesExists(
new TypesExistsRequest(
new String[]{indexName}, typeName));
TypesExistsResponse response = action.actionGet();
return response.isExists();
}
示例7: mappingExists
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
public boolean mappingExists(String indexName, String typeName) {
boolean result = false;
try {
String[] indices = new String[]{indexName};
TypesExistsResponse exists = client.admin().indices().typesExists(new TypesExistsRequest(indices, typeName)).actionGet();
result = exists.isExists();
} catch (Exception e) {
log.error("Error checking type exists");
}
return result;
}
示例8: toXContent
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(TypesExistsRequest request, TypesExistsResponse response, XContentBuilder builder) throws IOException {
builder.startObject();
builder.field(Fields.OK, response.isExists());
builder.endObject();
return builder;
}
示例9: typesExists
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
@Override
public ActionFuture<TypesExistsResponse> typesExists(TypesExistsRequest request) {
return execute(TypesExistsAction.INSTANCE, request);
}
示例10: isExistsIndexAndType
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
public static boolean isExistsIndexAndType(String indexName,String indexType){
TypesExistsResponse response = ESUtils.getClientInstance().admin().indices()
.typesExists(new TypesExistsRequest(new String[]{indexName}, indexType)).actionGet();
return response.isExists();
}
示例11: TypesExistsRequestBuilder
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
public TypesExistsRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) {
super(client, new TypesExistsRequest(new String[0]), jsonToString, stringToJson);
}
示例12: doExecute
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
@Override
protected ActionFuture<TypesExistsResponse> doExecute(TypesExistsRequest request) {
return client.admin().indices().typesExists(request);
}
示例13: typesExists
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
/**
* Types Exists.
*
* @param request The types exists request
* @return The result future
*/
ActionFuture<TypesExistsResponse> typesExists(TypesExistsRequest request);
示例14: isExistsType
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; //导入依赖的package包/类
/**
* 判断指定的索引的类型是否存在
*
* @param indexName
* 索引名
* @param indexType
* 索引类型
* @return 存在:true; 不存在:false;
*/
public boolean isExistsType(String indexName, String indexType) {
TypesExistsResponse response = client .admin().indices()
.typesExists(new TypesExistsRequest(new String[] { indexName }, indexType)).actionGet();
return response.isExists();
}