public void setMapping(String indexName, File json) { try { this.elasticsearchClient.admin().indices().preparePutMapping(indexName) .setSource(new String(Files.readAllBytes(json.toPath()), StandardCharsets.UTF_8)) .setUpdateAllTypes(true) .setType("_default_") .execute() .actionGet(); } catch (Throwable e) { DAO.severe(e); }; }
/** * 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" ); } }
/** * 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" ); } }
private void addMappingToIndex(String indexName, String mappingType, String mappingFilename) throws IOException { GetMappingsResponse getMappingsResponse = elasticSearchClient.admin() .indices() .prepareGetMappings(indexName) .addTypes(mappingType) .execute() .actionGet(); if (getMappingsResponse.mappings().isEmpty()) { logger.info("Adding the workflow type mappings"); InputStream stream = ElasticSearchDAOV5.class.getResourceAsStream(mappingFilename); byte[] bytes = IOUtils.toByteArray(stream); String source = new String(bytes); try { elasticSearchClient.admin() .indices() .preparePutMapping(indexName) .setType(mappingType) .setSource(source) .execute() .actionGet(); } catch (Exception e) { logger.error("Failed to init index mappings", e); } } }
PutMappingResponse response = client.admin().indices().preparePutMapping(indexName). setIgnoreConflicts(false).setType(store).setSource(mapping).execute().actionGet(); } catch (Exception e) {
PutMappingResponse pmr = client.admin().indices().preparePutMapping(index).setType(type) .setSource(mapping.getSourceAsMap()).get(); if (!pmr.isAcknowledged()) {
PutMappingResponse mappingResponse = SHARED_NODE.client().admin().indices().preparePutMapping(index.getName()) .setType(entry.getKey()) .setSource(entry.getValue().getAttributes())
logger.debug("Set explicit attachment mapping."); esClient.admin().indices().preparePutMapping(definition.getIndexName()).setType(definition.getTypeName()) .setSource(getGridFSMapping()).get(); } catch (Exception e) {
public void setMapping(String indexName, File json) { try { this.elasticsearchClient.admin().indices().preparePutMapping(indexName) .setSource(new String(Files.readAllBytes(json.toPath()), StandardCharsets.UTF_8), XContentType.JSON) .setUpdateAllTypes(true) .setType("_default_") .execute() .actionGet(); } catch (Throwable e) { Data.logger.warn("", e); }; }
public void setMapping(String indexName, XContentBuilder mapping) { try { this.elasticsearchClient.admin().indices().preparePutMapping(indexName) .setSource(mapping) .setUpdateAllTypes(true) .setType("_default_").execute().actionGet(); } catch (Throwable e) { Data.logger.warn("", e); }; }
public void setMapping(String indexName, Map<String, Object> mapping) { try { this.elasticsearchClient.admin().indices().preparePutMapping(indexName) .setSource(mapping) .setUpdateAllTypes(true) .setType("_default_").execute().actionGet(); } catch (Throwable e) { Data.logger.warn("", e); }; }
public void setMapping(String indexName, String mapping) { try { this.elasticsearchClient.admin().indices().preparePutMapping(indexName) .setSource(mapping, XContentType.JSON) .setUpdateAllTypes(true) .setType("_default_").execute().actionGet(); } catch (Throwable e) { Data.logger.warn("", e); }; }
public void recreateIndex() throws IOException { deleteIndex(); final Client client = this.getClient(); final InputStream mappings = Thread.currentThread().getContextClassLoader() .getResourceAsStream("mappings.json"); final InputStream index_settings = Thread.currentThread().getContextClassLoader() .getResourceAsStream("index_settings.json"); String mappingsString = IOUtils.toString(mappings); JSONObject mappingsJSON = new JSONObject(mappingsString); // add all langs to the mapping mappingsJSON = addLangsToMapping(mappingsJSON); client.admin().indices().prepareCreate("photon").setSettings(IOUtils.toString(index_settings)).execute() .actionGet(); client.admin().indices().preparePutMapping("photon").setType("place").setSource(mappingsJSON.toString()) .execute().actionGet(); log.info("mapping created: " + mappingsJSON.toString()); }
private PutMappingRequestBuilder updateMappingRequest(Index index, String type, Mapping mappingUpdate, final TimeValue timeout) { if (type.equals(MapperService.DEFAULT_MAPPING)) { throw new IllegalArgumentException("_default_ mapping should not be updated"); } return client.preparePutMapping().setConcreteIndex(index).setType(type).setSource(mappingUpdate.toString(), XContentType.JSON) .setMasterNodeTimeout(timeout).setTimeout(timeout); }
@Override public IndexShard createShard(ShardRouting shardRouting, RecoveryState recoveryState, PeerRecoveryTargetService recoveryTargetService, PeerRecoveryTargetService.RecoveryListener recoveryListener, RepositoriesService repositoriesService, Consumer<IndexShard.ShardFailure> onShardFailure, Consumer<ShardId> globalCheckpointSyncer) throws IOException { ensureChangesAllowed(); IndexService indexService = indexService(shardRouting.index()); IndexShard indexShard = indexService.createShard(shardRouting, globalCheckpointSyncer); indexShard.addShardFailureCallback(onShardFailure); indexShard.startRecovery(recoveryState, recoveryTargetService, recoveryListener, repositoriesService, (type, mapping) -> { assert recoveryState.getRecoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS: "mapping update consumer only required by local shards recovery"; client.admin().indices().preparePutMapping() .setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid .setType(type) .setSource(mapping.source().string(), XContentType.JSON) .get(); }, this); return indexShard; }
if (getTaskResultMappingVersion(metaData) < TASK_RESULT_MAPPING_VERSION) { client.admin().indices().preparePutMapping(TASK_INDEX).setType(TASK_TYPE) .setSource(taskResultIndexMapping(), XContentType.JSON) .execute(new ActionListener<AcknowledgedResponse>() {
@SuppressWarnings("rawtypes") private void createMapping(String indexName, String indexType, Map json) { if (json != null) { client.admin().indices().preparePutMapping(indexName).setType(indexType).setSource(json).execute() .actionGet(); } } }
@Override public void addMapping(XContentBuilder mapping) { esResource .getClient() .admin() .indices() .preparePutMapping(index) .setType(type) .setSource(mapping) .execute() .actionGet(); }
private static class StreamingPropertyString { private final String propertyValue; public StreamingPropertyString(String propertyValue) { this.propertyValue = propertyValue; } public String getPropertyValue() { return propertyValue; } }
@Override public <T> boolean putMapping(Class<T> clazz) { ElasticsearchPersistentEntity<T> persistentEntity = getPersistentEntityFor(clazz); PutMappingRequestBuilder requestBuilder = client.admin().indices().preparePutMapping(persistentEntity.getIndexName()) .setType(persistentEntity.getIndexType()); try { XContentBuilder xContentBuilder = buildMapping(clazz, persistentEntity.getIndexType(), persistentEntity.getIdProperty().getFieldName()); return requestBuilder.setSource(xContentBuilder).execute().actionGet().acknowledged(); } catch (Exception e) { throw new ElasticsearchException("Failed to build mapping for " + clazz.getSimpleName() , e); } }