Tabnine Logo
org.elasticsearch.action.admin.indices.mapping.put
Code IndexAdd Tabnine to your IDE (free)

How to use org.elasticsearch.action.admin.indices.mapping.put

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

origin: SonarSource/sonarqube

 @Override
 public String toString() {
  StringBuilder message = new StringBuilder();
  message.append("ES put mapping request");
  if (request.indices().length > 0) {
   message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
  }
  String type = request.type();
  if (type != null) {
   message.append(String.format(" on type '%s'", type));
  }
  String source = request.source();
  if (source != null) {
   message.append(String.format(" with source '%s'", source));
  }

  return message.toString();
 }
}
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: 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: SonarSource/sonarqube

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

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

      setIgnoreConflicts(false).setType(store).setSource(mapping).execute().actionGet();
} catch (Exception e) {
  throw convert(e);
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: 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: SonarSource/sonarqube

@Override
public PutMappingResponse get() {
 Profiler profiler = Profiler.createIfTrace(EsClient.LOGGER).start();
 try {
  return super.execute().actionGet();
 } catch (Exception e) {
  throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
 } finally {
  if (profiler.isTraceEnabled()) {
   profiler.stopTrace(toString());
  }
 }
}
origin: spring-projects/spring-data-elasticsearch

@Override
public boolean putMapping(String indexName, String type, Object mapping) {
  Assert.notNull(indexName, "No index defined for putMapping()");
  Assert.notNull(type, "No type defined for putMapping()");
  PutMappingRequest request = new PutMappingRequest(indexName).type(type);
  if (mapping instanceof String) {
    request.source(String.valueOf(mapping), XContentType.JSON);
  } else if (mapping instanceof Map) {
    request.source((Map) mapping);
  } else if (mapping instanceof XContentBuilder) {
    request.source((XContentBuilder) mapping);
  }
  try {
    return client.indices().putMapping(request).isAcknowledged();
  } catch (IOException e) {
    throw new ElasticsearchException("Failed to put mapping for " + indexName, e);
  }
}
origin: SonarSource/sonarqube

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

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 {
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 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: SonarSource/sonarqube

@Test
public void execute_should_throw_an_unsupported_operation_exception() {
 try {
  es.client().preparePutMapping().execute();
  fail();
 } catch (Exception e) {
  assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
 }
}
origin: floragunncom/search-guard

tc.admin().indices().create(new CreateIndexRequest("u")).actionGet();
tc.admin().indices().putMapping(new PutMappingRequest("a").type("b")
                 .source("_source","enabled=false","content","store=true,type=text","field1","store=true,type=text", "field2","store=true,type=text", "a","store=true,type=text", "b","store=true,type=text", "my.nested.field","store=true,type=text")
                 ).actionGet();
tc.admin().indices().putMapping(new PutMappingRequest("c").type("d")
.source("_source","enabled=false","content","store=true,type=text","field1","store=true,type=text", "field2","store=true,type=text", "a","store=true,type=text", "b","store=true,type=text", "my.nested.field","store=true,type=text")
).actionGet();
tc.admin().indices().putMapping(new PutMappingRequest("test").type("type1")
.source("_source","enabled=false","content","store=true,type=text","field1","store=true,type=text", "field2","store=true,type=text", "a","store=true,type=text", "b","store=true,type=text", "my.nested.field","store=true,type=text")
).actionGet();
tc.admin().indices().putMapping(new PutMappingRequest("u").type("b")
.source("_source","enabled=false","content","store=true,type=text","field1","store=true,type=text", "field2","store=true,type=text", "a","store=true,type=text", "b","store=true,type=text", "my.nested.field","store=true,type=text")
).actionGet();
origin: SonarSource/sonarqube

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

 .setType(entry.getKey())
 .setSource(entry.getValue().getAttributes())
 .get();
if (!mappingResponse.isAcknowledged()) {
 throw new IllegalStateException("Failed to create type " + entry.getKey());
origin: floragunncom/search-guard

  tc.admin().indices().putMapping(new PutMappingRequest("test").type("typex").source("fieldx","type=text")).actionGet();
  Assert.fail();
} catch (ElasticsearchSecurityException e) {
origin: SonarSource/sonarqube

@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");
 }
}
org.elasticsearch.action.admin.indices.mapping.put

Most used classes

  • PutMappingRequestBuilder
    Builder for a put mapping request
  • PutMappingResponse
    The response of put mapping operation.
  • PutMappingRequest
    Puts mapping definition registered under a specific type into one or more indices. Best created with
  • PutMappingClusterStateUpdateRequest
    Cluster state update request that allows to put a mapping
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