Refine search
/** * Setup ElasticSearch type mappings as a template that applies to all new indexes. * Applies to all indexes that* start with our prefix. */ private void createMappings(final String indexName) { //Added For Graphite Metrics PutMappingResponse pitr = provider.getClient().admin().indices().preparePutMapping( indexName ).setType( "entity" ).setSource( getMappingsContent() ).execute().actionGet(); if ( !pitr.isAcknowledged() ) { throw new RuntimeException( "Unable to create default mappings" ); } }
LOGGER.info(String.format("Create type %s/%s", index.getName(), entry.getKey())); PutMappingResponse mappingResponse = client.preparePutMapping(index.getName()) .setType(entry.getKey()) .setSource(entry.getValue().getAttributes()) .get(); if (!mappingResponse.isAcknowledged()) { throw new IllegalStateException("Failed to create type " + entry.getKey());
@Override public Table execute() throws MetaModelException { final MutableTable table = getTable(); final Map<String, ?> source = ElasticSearchUtils.getMappingSource(table); final ElasticSearchDataContext dataContext = getUpdateCallback().getDataContext(); final IndicesAdminClient indicesAdmin = dataContext.getElasticSearchClient().admin().indices(); final String indexName = dataContext.getIndexName(); final PutMappingRequestBuilder requestBuilder = new PutMappingRequestBuilder(indicesAdmin, PutMappingAction.INSTANCE).setIndices(indexName) .setType(table.getName()); requestBuilder.setSource(source); final PutMappingResponse result = requestBuilder.execute().actionGet(); logger.debug("PutMapping response: acknowledged={}", result.isAcknowledged()); dataContext.getElasticSearchClient().admin().indices().prepareRefresh(indexName).get(); final MutableSchema schema = (MutableSchema) getSchema(); schema.addTable(table); return table; }
PutMappingRequestBuilder pmrb = this.client.admin().indices().preparePutMapping(INDEX_NAME) .setType("backup"); pmrb.setSource(this.getIndexCustomFieldMapping()); PutMappingResponse putMappingResponse = pmrb.execute().actionGet(); if (!putMappingResponse.isAcknowledged()) { this.logger.error("Could not create index [" + INDEX_NAME + " ]."); } else { this.logger.debug("Successfully created index [" + INDEX_NAME + " ]."); }
.preparePutMapping(index) .setType(type); pmrb.setSource(source); MappingListener mappingListener = new MappingListener(pmrb) if (response.isAcknowledged()) { System.out.println("template successfully applied")
/** * Update mappings synchronously on the master node, waiting for at most * {@code timeout}. When this method returns successfully mappings have * been applied to the master node and propagated to data nodes. */ public void updateMappingOnMasterSynchronously(String index, String type, Mapping mappingUpdate, TimeValue timeout) throws Throwable { if (updateMappingRequest(index, type, mappingUpdate, timeout).get().isAcknowledged() == false) { throw new TimeoutException("Failed to acknowledge mapping update within [" + timeout + "]"); } }
@Override public void onResponse(PutMappingResponse putMappingResponse) { JsonObject json = new JsonObject() .put("acknowledged", putMappingResponse.isAcknowledged()); resultHandler.handle(Future.succeededFuture(json)); }
@Override public PutMappingResponse newResponse() { return new PutMappingResponse(); }
public static PutMappingResponse fromXContent(XContentParser parser) { return new PutMappingResponse(parseAcknowledged(parser)); } }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); readAcknowledged(in); }
@Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); writeAcknowledged(out); } }
PutMappingResponse pmr = client.admin().indices().preparePutMapping(index).setType(type) .setSource(mapping.getSourceAsMap()).get(); if (!pmr.isAcknowledged()) { logger.error("Failed to put mapping {} / {} / {}.", index, type, mapping.source()); } else {
@Override public Table execute() throws MetaModelException { final MutableTable table = getTable(); final Map<String, ?> source = ElasticSearchUtils.getMappingSource(table); final ElasticSearchDataContext dataContext = getUpdateCallback().getDataContext(); final IndicesAdminClient indicesAdmin = dataContext.getElasticSearchClient().admin().indices(); final String indexName = dataContext.getIndexName(); final PutMappingRequestBuilder requestBuilder = new PutMappingRequestBuilder(indicesAdmin, PutMappingAction.INSTANCE).setIndices(indexName) .setType(table.getName()); requestBuilder.setSource(source); final PutMappingResponse result = requestBuilder.execute().actionGet(); logger.debug("PutMapping response: acknowledged={}", result.isAcknowledged()); dataContext.getElasticSearchClient().admin().indices().prepareRefresh(indexName).get(); final MutableSchema schema = (MutableSchema) getSchema(); schema.addTable(table); return table; }
.setType("document"); pmrb.setSource(xb); PutMappingResponse response = pmrb.execute().actionGet(); if (!response.isAcknowledged()) { LOG.info("Error while creating mapping for user document."); } else {
/** * Update mappings synchronously on the master node, waiting for at most * {@code timeout}. When this method returns successfully mappings have * been applied to the master node and propagated to data nodes. */ public void updateMappingOnMaster(Index index, String type, Mapping mappingUpdate, TimeValue timeout) throws Exception { if (updateMappingRequest(index, type, mappingUpdate, timeout).get().isAcknowledged() == false) { throw new TimeoutException("Failed to acknowledge mapping update within [" + timeout + "]"); } } }
@Override protected XContentBuilder toXContent(PutMappingRequest request, PutMappingResponse response, XContentBuilder builder) throws IOException { builder.startObject() .field(Fields.OK, true) .field(Fields.ACKNOWLEDGED, response.isAcknowledged()); builder.endObject(); return builder; } }
@Override protected PutMappingResponse newResponse() { return new PutMappingResponse(); }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); readAcknowledged(in); }
@Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); writeAcknowledged(out); } }
/** * Setup ElasticSearch type mappings as a template that applies to all new indexes. * Applies to all indexes that* start with our prefix. */ private void createMappings(final String indexName) throws IOException { //Added For Graphite Metrics Timer.Context timePutIndex = mappingTimer.time(); PutMappingResponse pitr = esProvider.getClient().admin().indices().preparePutMapping( indexName ).setType( "entity" ).setSource( getMappingsContent() ).execute().actionGet(); timePutIndex.stop(); if ( !pitr.isAcknowledged() ) { throw new IndexException( "Unable to create default mappings" ); } }