Package org.elasticsearch.action.admin.indices.mapping.put

Examples of org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse


        logger.info("Creating index [{}]", "test");
        client("server1").admin().indices().prepareCreate("test").execute().actionGet();

        // create a mapping
        PutMappingResponse putMappingResponse = client("server1").admin().indices().preparePutMapping("test").setType("type1").setSource(mappingSource()).execute().actionGet();
        assertThat(putMappingResponse.acknowledged(), equalTo(true));

        // verify that mapping is there
        ClusterStateResponse clusterState = client("server1").admin().cluster().state(clusterStateRequest()).actionGet();
        assertThat(clusterState.state().metaData().index("test").mapping("type1"), notNullValue());
View Full Code Here


        assertThat(clusterHealth.timedOut(), equalTo(false));
        assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));

        // Translog tests
        // create a mapping
        PutMappingResponse putMappingResponse = node.client().admin().indices().putMapping(putMappingRequest("test").type("type1")
                .source(mappingSource())).actionGet();
        assertThat(putMappingResponse.acknowledged(), equalTo(true));

        // verify that mapping is there
        ClusterStateResponse clusterState = node.client().admin().cluster().state(clusterStateRequest()).actionGet();
        assertThat(clusterState.state().metaData().index("test").mapping("type1"), notNullValue());
View Full Code Here

            // Read the mapping json file if exists and use it
            if (xcontent != null) {
                if (logger.isTraceEnabled()) logger.trace("Mapping for ["+index+"]/["+type+"]="+xcontent.string());
                // Create type and mapping
                PutMappingResponse response = client.admin().indices()
                        .preparePutMapping(index)
                        .setType(type)
                        .setSource(xcontent)
                        .execute().actionGet();
                if (!response.isAcknowledged()) {
                    throw new Exception("Could not define mapping for type ["+index+"]/["+type+"].");
                } else {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Mapping definition for ["+index+"]/["+type+"] succesfully created.");
                    }
View Full Code Here

        }
    }

    private void createMapping(final String robotIndexName, final String type,
            final XContentBuilder builder) {
        final PutMappingResponse queueMappingResponse = client.admin()
                .indices().preparePutMapping(robotIndexName).setType(type)
                .setSource(builder).execute().actionGet();
        if (!queueMappingResponse.isAcknowledged()) {
            logger.warn("Failed to create " + type + " mapping.");
        }
    }
View Full Code Here

     * @param indexType
     * @param indexMapping
     */
    public static PutMappingResponse createMapping(String indexName, String indexType, String indexMapping) {
        Logger.debug("ElasticSearch : creating mapping [" + indexName + "/" + indexType + "] :  " + indexMapping);
        PutMappingResponse response = IndexClient.client.admin().indices().preparePutMapping(indexName).setType(indexType).setSource(indexMapping).execute().actionGet();
        return response;
    }
View Full Code Here

      Logger.debug("Create Elastic Search Type %s/%s", indexName, typeName);
      PutMappingRequest request = Requests.putMappingRequest(indexName).type(typeName);
      XContentBuilder mapping = MappingUtil.getMapping(mapper);
      Logger.debug("Type mapping: \n %s", mapping.string());
      request.source(mapping);
      PutMappingResponse response = client.admin().indices().putMapping(request).actionGet();
      Logger.debug("Response: %s", response);

    } catch (IndexAlreadyExistsException iaee) {
      Logger.debug("Index already exists: %s", indexName);
View Full Code Here

            //Put the schema/mapping
            log.info("Put Mapping for ["+indexName+"]/["+indexType+"]="+stringMappingJSON);
            PutMappingRequestBuilder putMappingRequestBuilder = client.admin().indices().preparePutMapping(indexName).setType(indexType);
            putMappingRequestBuilder.setSource(stringMappingJSON);
            PutMappingResponse response = putMappingRequestBuilder.execute().actionGet();

            if(!response.isAcknowledged()) {
                log.info("Could not define mapping for type ["+indexName+"]/["+indexType+"]");
            } else {
                log.info("Successfully put mapping for ["+indexName+"]/["+indexType+"]");
            }
View Full Code Here

        } catch (IOException e) {
            throw new PermanentStorageException("Could not render json for put mapping request", e);
        }

        try {
            PutMappingResponse response = client.admin().indices().preparePutMapping(indexName).
                    setIgnoreConflicts(false).setType(store).setSource(mapping).execute().actionGet();
        } catch (Exception e) {
            throw convert(e);
        }
    }
View Full Code Here

      // Read the mapping json file if exists and use it
      String source = readMapping(index, type);
      if (source != null) {
        if (logger.isTraceEnabled()) logger.trace("Mapping for ["+index+"]/["+type+"]="+source);
        // Create type and mapping
        PutMappingResponse response = client.admin().indices()
          .preparePutMapping(index)
          .setType(type)
          .setSource(source)
          .execute().actionGet();     
        if (!response.isAcknowledged()) {
          throw new Exception("Could not define mapping for type ["+index+"]/["+type+"].");
        } else {
          if (logger.isDebugEnabled()) {
            if (mappingExist) {
              logger.debug("Mapping definition for ["+index+"]/["+type+"] succesfully merged.");
View Full Code Here

                 * mapping metadata (in case it is has been customized before to
                 * delete.
                 */
                MappingMetaData mapping = mappings.get(type);
                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());
                    } else {
                        logger.info("Delete and recreate for index / type [{}] [{}] successfully executed.", index, type);
                    }
                } else {
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.