Java Code Examples for org.elasticsearch.action.support.master.AcknowledgedResponse#isAcknowledged()
The following examples show how to use
org.elasticsearch.action.support.master.AcknowledgedResponse#isAcknowledged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpgradeUtil.java From fess with Apache License 2.0 | 6 votes |
public static boolean addFieldMapping(final IndicesAdminClient indicesClient, final String index, final String type, final String field, final String source) { final GetFieldMappingsResponse gfmResponse = indicesClient.prepareGetFieldMappings(index).addTypes(type).setFields(field).execute().actionGet(); final FieldMappingMetadata fieldMappings = gfmResponse.fieldMappings(index, type, field); if (fieldMappings == null || fieldMappings.isNull()) { try { final AcknowledgedResponse pmResponse = indicesClient.preparePutMapping(index).setSource(source, XContentType.JSON).execute().actionGet(); if (!pmResponse.isAcknowledged()) { logger.warn("Failed to add {} to {}/{}", field, index, type); } else { return true; } } catch (final Exception e) { logger.warn("Failed to add " + field + " to " + index + "/" + type, e); } } return false; }
Example 2
Source File: ElasticSearch7Client.java From skywalking with Apache License 2.0 | 6 votes |
public boolean createTemplate(String indexName, Map<String, Object> settings, Map<String, Object> mapping) throws IOException { indexName = formatIndexName(indexName); PutIndexTemplateRequest putIndexTemplateRequest = new PutIndexTemplateRequest(indexName).patterns( Collections.singletonList(indexName + "-*")) .alias(new Alias( indexName)) .settings(settings) .mapping(mapping); AcknowledgedResponse acknowledgedResponse = client.indices() .putTemplate(putIndexTemplateRequest, RequestOptions.DEFAULT); return acknowledgedResponse.isAcknowledged(); }
Example 3
Source File: ElasticSearch7Client.java From skywalking with Apache License 2.0 | 5 votes |
public boolean deleteTemplate(String indexName) throws IOException { indexName = formatIndexName(indexName); DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(indexName); AcknowledgedResponse acknowledgedResponse = client.indices() .deleteTemplate( deleteIndexTemplateRequest, RequestOptions.DEFAULT); return acknowledgedResponse.isAcknowledged(); }
Example 4
Source File: UpgradeUtil.java From fess with Apache License 2.0 | 5 votes |
public static boolean putMapping(final IndicesAdminClient indicesClient, final String index, final String type, final String source) { try { final PutMappingRequestBuilder builder = indicesClient.preparePutMapping(index).setSource(source, XContentType.JSON); final AcknowledgedResponse pmResponse = builder.execute().actionGet(); if (!pmResponse.isAcknowledged()) { logger.warn("Failed to update {} settings.", index); } else { return true; } } catch (final Exception e) { logger.warn("Failed to update " + index + " settings.", e); } return false; }
Example 5
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 5 votes |
public AcknowledgedResponse updateAlias(final BuilderCallback<IndicesAliasesRequestBuilder> builder) { final AcknowledgedResponse actionGet = builder.apply(client().admin().indices().prepareAliases()).execute().actionGet(); if (!actionGet.isAcknowledged()) { onFailure("Failed to update aliases.", actionGet); } return actionGet; }
Example 6
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 5 votes |
public AcknowledgedResponse createMapping(final String index, final BuilderCallback<PutMappingRequestBuilder> builder) { final AcknowledgedResponse actionGet = builder.apply(client().admin().indices().preparePutMapping(index)).execute().actionGet(); if (!actionGet.isAcknowledged()) { onFailure("Failed to create a mapping for " + index + ".", actionGet); } return actionGet; }
Example 7
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 5 votes |
public AcknowledgedResponse deleteIndex(final String index, final BuilderCallback<DeleteIndexRequestBuilder> builder) { final AcknowledgedResponse actionGet = builder.apply(client().admin().indices().prepareDelete(index)).execute().actionGet(); if (!actionGet.isAcknowledged()) { onFailure("Failed to create " + index + ".", actionGet); } return actionGet; }
Example 8
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 5 votes |
public AcknowledgedResponse closeIndex(final String index, final BuilderCallback<CloseIndexRequestBuilder> builder) { final AcknowledgedResponse actionGet = builder.apply(client().admin().indices().prepareClose(index)).execute().actionGet(); if (!actionGet.isAcknowledged()) { onFailure("Failed to close " + index + ".", actionGet); } return actionGet; }
Example 9
Source File: RestHighLevelClientCase.java From skywalking with Apache License 2.0 | 5 votes |
private void delete(RestHighLevelClient client, String indexName) throws IOException { DeleteIndexRequest request = new DeleteIndexRequest(indexName); AcknowledgedResponse deleteIndexResponse = client.indices().delete(request, RequestOptions.DEFAULT); if (!deleteIndexResponse.isAcknowledged()) { String message = "elasticsearch delete index fail."; logger.error(message); throw new RuntimeException(message); } }
Example 10
Source File: CaseController.java From skywalking with Apache License 2.0 | 5 votes |
private void delete(String indexName) throws IOException { DeleteIndexRequest request = new DeleteIndexRequest(indexName); AcknowledgedResponse deleteIndexResponse = client.indices().delete(request, RequestOptions.DEFAULT); if (!deleteIndexResponse.isAcknowledged()) { String message = "elasticsearch delete index fail."; logger.error(message); throw new RuntimeException(message); } }
Example 11
Source File: ElasticSearch7Client.java From skywalking with Apache License 2.0 | 5 votes |
protected boolean deleteIndex(String indexName, boolean formatIndexName) throws IOException { if (formatIndexName) { indexName = formatIndexName(indexName); } DeleteIndexRequest request = new DeleteIndexRequest(indexName); AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT); log.debug("delete {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); return response.isAcknowledged(); }
Example 12
Source File: AliasElasticsearchUpdater.java From elasticsearch-beyonder with Apache License 2.0 | 5 votes |
/** * Create an alias if needed * @param client Client to use * @param alias Alias name * @param index Index name * @throws Exception When alias can not be set */ @Deprecated public static void createAlias(Client client, String alias, String index) throws Exception { logger.trace("createAlias({},{})", alias, index); AcknowledgedResponse response = client.admin().indices().prepareAliases().addAlias(index, alias).get(); if (!response.isAcknowledged()) throw new Exception("Could not define alias [" + alias + "] for index [" + index + "]."); logger.trace("/createAlias({},{})", alias, index); }
Example 13
Source File: ElasticSearchService.java From pybbs with GNU Affero General Public License v3.0 | 5 votes |
public boolean deleteIndex() { try { if (this.instance() == null) return false; DeleteIndexRequest request = new DeleteIndexRequest(name); request.indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN); AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT); return response.isAcknowledged(); } catch (IOException e) { log.error(e.getMessage()); return false; } }
Example 14
Source File: ElasticsearchTemplate.java From summerframework with Apache License 2.0 | 5 votes |
public boolean deleteIndex(String index) { if (!isExistedIndex(index)) { return false; } AcknowledgedResponse deleteIndexResponse = esClient.admin().indices().prepareDelete(index).execute().actionGet(); return deleteIndexResponse.isAcknowledged(); }
Example 15
Source File: ElasticsearchTemplate.java From summerframework with Apache License 2.0 | 5 votes |
public boolean createMapping(String index, String type, XContentBuilder mapping) throws IOException { log.info("mapping is:{}", mapping.toString()); PutMappingRequest mappingRequest = Requests.putMappingRequest(index).source(mapping).type(type); AcknowledgedResponse putMappingResponse = esClient.admin().indices().putMapping(mappingRequest).actionGet(); return putMappingResponse.isAcknowledged(); }
Example 16
Source File: ElasticsearchTemplate.java From summerframework with Apache License 2.0 | 5 votes |
public boolean deleteIndex(String index) { if (!isExistedIndex(index)) { return false; } AcknowledgedResponse deleteIndexResponse = esClient.admin().indices().prepareDelete(index).execute().actionGet(); return deleteIndexResponse.isAcknowledged(); }
Example 17
Source File: ElasticsearchTemplate.java From summerframework with Apache License 2.0 | 5 votes |
public boolean createMapping(String index, String type, XContentBuilder mapping) throws IOException { log.info("mapping is:{}", mapping.toString()); PutMappingRequest mappingRequest = Requests.putMappingRequest(index).source(mapping).type(type); AcknowledgedResponse putMappingResponse = esClient.admin().indices().putMapping(mappingRequest).actionGet(); return putMappingResponse.isAcknowledged(); }
Example 18
Source File: IndexServiceImpl.java From microservices-platform with Apache License 2.0 | 4 votes |
@Override public boolean delete(String indexName) throws IOException { DeleteIndexRequest request = new DeleteIndexRequest(indexName); AcknowledgedResponse response = elasticsearchRestTemplate.getClient().indices().delete(request, RequestOptions.DEFAULT); return response.isAcknowledged(); }