Tabnine Logo
PutMappingRequestBuilder.setSource
Code IndexAdd Tabnine to your IDE (free)

How to use
setSource
method
in
org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder

Best Java code snippets using org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.setSource (Showing top 20 results out of 531)

origin: loklak/loklak_server

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);
  };
}
origin: apache/usergrid

/**
 * 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" );
  }
}
origin: Netflix/conductor

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);
    }
  }
}
origin: apache/usergrid

/**
 * 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" );
  }
}
origin: SonarSource/sonarqube

@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}}'");
}
origin: thinkaurelius/titan

      setIgnoreConflicts(false).setType(store).setSource(mapping).execute().actionGet();
} catch (Exception e) {
  throw convert(e);
origin: SonarSource/sonarqube

PutMappingResponse mappingResponse = client.preparePutMapping(index.getName())
 .setType(entry.getKey())
 .setSource(entry.getValue().getAttributes())
 .get();
if (!mappingResponse.isAcknowledged()) {
origin: SonarSource/sonarqube

@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);
}
origin: richardwilly98/elasticsearch-river-mongodb

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());
origin: SonarSource/sonarqube

@Test
public void put_mapping() {
 PutMappingRequestBuilder requestBuilder = es.client().preparePutMapping(FakeIndexDefinition.INDEX)
  .setType(FakeIndexDefinition.TYPE)
  .setSource(mapDomain());
 requestBuilder.get();
}
origin: SonarSource/sonarqube

PutMappingResponse mappingResponse = SHARED_NODE.client().admin().indices().preparePutMapping(index.getName())
 .setType(entry.getKey())
 .setSource(entry.getValue().getAttributes())
 .get();
if (!mappingResponse.isAcknowledged()) {
origin: yacy/yacy_grid_mcp

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);
  };
}
origin: richardwilly98/elasticsearch-river-mongodb

      .setSource(getGridFSMapping()).get();
} catch (Exception e) {
  logger.warn("Failed to set explicit mapping (attachment): {}", e);
origin: yacy/yacy_grid_mcp

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);
  };
}
origin: yacy/yacy_grid_mcp

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);
  };
}
origin: yacy/yacy_grid_mcp

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);
  };
}
origin: komoot/photon

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());
}
origin: org.elasticsearch/elasticsearch

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);
}
origin: org.elasticsearch/elasticsearch

@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;
}
origin: org.elasticsearch/elasticsearch

.setSource(taskResultIndexMapping(), XContentType.JSON)
.execute(new ActionListener<AcknowledgedResponse>() {
       @Override
org.elasticsearch.action.admin.indices.mapping.putPutMappingRequestBuildersetSource

Javadoc

The mapping source definition.

Popular methods of PutMappingRequestBuilder

  • setType
    The type of the mappings.
  • execute
  • get
  • setIgnoreConflicts
  • setIndices
  • <init>
  • setMasterNodeTimeout
  • setTimeout
  • setConcreteIndex
  • setUpdateAllTypes
    True if all fields that span multiple types should be updated, false otherwise

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JCheckBox (javax.swing)
  • Join (org.hibernate.mapping)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now