@Test public void fail_on_bad_query() { try { es.client().preparePutMapping().get(); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class); assertThat(e.getMessage()).contains("Fail to execute ES put mapping request"); } }
@Test public void get_with_string_timeout_is_not_yet_implemented() { try { es.client().preparePutMapping().get("1"); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().preparePutMapping().get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
.setType(entry.getKey()) .setSource(entry.getValue().getAttributes()) .get(); if (!mappingResponse.isAcknowledged()) { throw new IllegalStateException("Failed to create type " + entry.getKey());
@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); }
if (client.admin().indices().prepareDeleteMapping(index).setType(type).get().isAcknowledged()) { 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());
@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(); if (!mappingResponse.isAcknowledged()) { throw new IllegalStateException("Failed to create type " + entry.getKey());
.setSource(getGridFSMapping()).get(); } catch (Exception e) { logger.warn("Failed to set explicit mapping (attachment): {}", e);
/** * 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) { if (updateMappingRequest(index, type, mappingUpdate, timeout).get().isAcknowledged() == false) { throw new ElasticsearchTimeoutException("Failed to acknowledge mapping update within [" + 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; }
/** * 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 + "]"); } } }
/** * 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 createMapping(String indexName, String type, String jsonMapping) { client.admin() .indices() .preparePutMapping(indexName) .setType(type) .setSource(jsonMapping, XContentType.JSON) .get(); }
/** * 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) { if (updateMappingRequest(index, type, mappingUpdate, timeout).get().isAcknowledged() == false) { throw new ElasticsearchTimeoutException("Failed to acknowledge mapping update within [" + timeout + "]"); } } }
/** * 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) { if (updateMappingRequest(index, type, mappingUpdate, timeout).get().isAcknowledged() == false) { throw new ElasticsearchTimeoutException("Failed to acknowledge mapping update within [" + timeout + "]"); } } }
@Override public void updateDocumentTypeMapping(ElasticSearchIndexConfig config, String documentType, boolean parentRelationship) { try { searchClientService.getClient().admin().indices().preparePutMapping(config.getIndexAliasName()) .setType(documentType) .setSource(new IndexSchemaBuilder().getDocumentTypeMapping(config, documentType, parentRelationship)) .get(); } catch (IOException e) { throw new RuntimeException("Error occurend while generating mapping for document type", e); } }
public void putMapping(String index, String type, List<MetaProperty> metaProperties) { checkNotEmpty("index", index); checkNotEmpty("type", type); Map<String, Object> properties = this.createMappingMap(metaProperties); this.getClient().admin().indices().preparePutMapping(sanitizeIndex(index)).setType(sanitizeIndex(type)).setSource(properties).get(); }
public void putMapping(String index, String type, List<MetaProperty> metaProperties) { checkNotEmpty("index", index); checkNotEmpty("type", type); Map<String, Object> properties = this.createMappingMap(metaProperties); this.getClient().admin().indices().preparePutMapping(sanitizeIndex(index)).setType(sanitizeIndex(type)).setSource(properties).get(); }
public void putMapping(String index, String type, MetaObject metaObject) { checkNotEmpty("index", index); checkNotEmpty("type", type); checkNotNull("metaObject", metaObject); try { this.getClient().admin().indices().prepareCreate(sanitizeIndex(index)).get(); } catch (ResourceAlreadyExistsException ex) { logger.debug("Resource Already exists: " + ex.getMessage()); } Map<String, Object> properties = this.createMappingMap(metaObject.getProperties()); this.getClient().admin().indices() .preparePutMapping(sanitizeIndex(index)) .setType(sanitizeIndex(type)) .setSource(properties).get(); }