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" ); } }
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); } } }
/** * 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" ); } }
setIgnoreConflicts(false).setType(store).setSource(mapping).execute().actionGet(); } catch (Exception e) { throw convert(e);
@Test public void to_string() { assertThat(es.client().preparePutMapping(FakeIndexDefinition.INDEX).setSource(mapDomain()).toString()) .isEqualTo("ES put mapping request on indices 'fakes' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'"); assertThat(es.client().preparePutMapping(FakeIndexDefinition.INDEX).setType(FakeIndexDefinition.TYPE).setSource(mapDomain()).toString()) .isEqualTo("ES put mapping request on indices 'fakes' on type 'fake' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'"); }
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();
@Test public void trace_logs() { logTester.setLevel(LoggerLevel.TRACE); PutMappingRequestBuilder requestBuilder = es.client().preparePutMapping(FakeIndexDefinition.INDEX) .setType(FakeIndexDefinition.TYPE) .setSource(mapDomain()); requestBuilder.get(); assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); }
PutMappingResponse pmr = client.admin().indices().preparePutMapping(index).setType(type) .setSource(mapping.getSourceAsMap()).get(); if (!pmr.isAcknowledged()) {
@Test public void put_mapping() { PutMappingRequestBuilder requestBuilder = es.client().preparePutMapping(FakeIndexDefinition.INDEX) .setType(FakeIndexDefinition.TYPE) .setSource(mapDomain()); requestBuilder.get(); }
.setType(entry.getKey()) .setSource(entry.getValue().getAttributes()) .get();
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); }; }
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, 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 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 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>() {