本文整理汇总了Java中org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse类的典型用法代码示例。如果您正苦于以下问题:Java TypesExistsResponse类的具体用法?Java TypesExistsResponse怎么用?Java TypesExistsResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypesExistsResponse类属于org.elasticsearch.action.admin.indices.exists.types包,在下文中一共展示了TypesExistsResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareRequest
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的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.TypesExistsResponse; //导入依赖的package包/类
@Override
public ActionFuture<TypesExistsResponse> typesExists(TypesExistsRequest request) {
return execute(TypesExistsAction.INSTANCE, request);
}
示例10: isExistsIndexAndType
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; //导入依赖的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: existsType
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; //导入依赖的package包/类
public TypesExistsResponse existsType(String index, String type) {
return client.admin().indices().prepareTypesExists(index)
.setTypes(type).execute().actionGet();
}
示例12: creaEsMapping
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; //导入依赖的package包/类
private void creaEsMapping(String index, String type,QueryCep query) throws Exception{
//Preparamos los campos geo_point y timestamp
Map<String,String> mapCamposFormato = new HashMap<String,String>();
String[] camposNombre = query.getOutputFieldNames().split(",");
String[] camposFormato = query.getOutputFieldFormat().split(",");
String lastField="";
if(camposNombre.length==camposFormato.length){
for(int i = 0;i<camposNombre.length;i++){
String []part =camposFormato[i].trim().replace('\n',' ').replace('\t',' ').replace(" ", " ").replace('\n',' ').split(" ");
mapCamposFormato.put(part[0].trim().toUpperCase(),part[1].trim());
}
}else{
//Lanzar excepcion (Creaarla)
throw new Exception("ERROR en QUERY: "+query.getQueryName()+"\\nLa cantidad de Campos de la query y de la salida a ElasticSearch no coinciden");
}
LOG.debug("Formatos Obtenidos");
//Generamos el JSON del Mapping
XContentBuilder mappingBuilder;
mappingBuilder = jsonBuilder().startObject()
.startObject(type)
.startObject("properties");
//por cada campo, lo a�adimos con su formato
for(int i = 0;i<camposNombre.length;i++){
mappingBuilder.startObject(camposNombre[i].trim())
.field("type",mapCamposFormato.get(camposNombre[i].trim().toUpperCase()));
if(mapCamposFormato.get(camposNombre[i].trim().toUpperCase())==null){
throw new Exception("ERROR en QUERY: "+query.getQueryName()+".\nEl campo: \""+camposNombre[i].trim()+"\" definido en \"QUERY AS\" no coincide con los definidos en \"FORMATO ES\" .");
}
if(mapCamposFormato.get(camposNombre[i].trim().toUpperCase()).toLowerCase().equals("string")){
mappingBuilder.field("index", "not_analyzed");
}
if(mapCamposFormato.get(camposNombre[i].trim().toUpperCase()).toLowerCase().equals("date")){
mappingBuilder.field("format","yyyy-MM-dd HH:mm:ss");
}
mappingBuilder.endObject();
}
mappingBuilder.endObject();
//A�adir el TTL si est� indicado, por defecto ponemos 60s
String ttl=query.getEsTTL();
if(ttl!= null && !ttl.equals("")){
mappingBuilder.startObject("_ttl").field("enabled", "true").field("default", ttl).endObject();
}else{
mappingBuilder.startObject("_ttl").field("enabled", "true").field("default", "60s").endObject();
}
mappingBuilder.endObject();
LOG.info(mappingBuilder.string());
//Comprobar si existe el indice
IndicesExistsResponse resp = this.client.admin().indices().prepareExists(index).execute().actionGet();
if(resp.isExists()){
//Comprobar si existe el type
TypesExistsResponse existeType = this.client.admin().indices().prepareTypesExists(index).setTypes(type).execute().actionGet();
if(existeType.isExists()){
//Si existe el type, lo borramos
this.client.admin().indices().prepareDeleteMapping(index).setType(type).execute().actionGet();
}
//Crear el nuevo mapping
this.client.admin().indices().preparePutMapping(index).setType(type).setSource(mappingBuilder).execute().actionGet();
}else{
//Crear e mapping desde cero con el index
client.admin().indices().prepareCreate(index).addMapping(type, mappingBuilder).execute().actionGet();
}
}
示例13: doExecute
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; //导入依赖的package包/类
@Override
protected ActionFuture<TypesExistsResponse> doExecute(TypesExistsRequest request) {
return client.admin().indices().typesExists(request);
}
示例14: typesExists
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; //导入依赖的package包/类
/**
* Types Exists.
*
* @param request The types exists request
* @return The result future
*/
ActionFuture<TypesExistsResponse> typesExists(TypesExistsRequest request);
示例15: isExistsType
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; //导入依赖的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();
}