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

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


        node.client().admin().indices().prepareCreate("es004index").execute().actionGet();

        XContentBuilder xbMapping = buildMapping();
        logger.info("Mapping is : {}", xbMapping.string());

        PutMappingResponse response = node.client().admin().indices()
            .preparePutMapping("es004index")
            .setType("type1")
            .setSource(xbMapping)
            .execute().actionGet();
        if (!response.isAcknowledged()) {
            throw new Exception("Could not define mapping.");
        }
        node.client().admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();

        node.client().prepareIndex("es004index", "type1").setSource("{\"location\" : { \"lat\" : 5, \"lon\" : 5 }}").execute().actionGet();
View Full Code Here


    @Test
    public void testPutMappingNoAcknowledgement() {
        createIndex("test");
        ensureGreen();

        PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("test").setSource("field", "type=string,index=not_analyzed").setTimeout("0s").get();
        assertThat(putMappingResponse.isAcknowledged(), equalTo(false));
    }
View Full Code Here

        assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("loading"), equalTo("lazy"));
        assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("format"), equalTo("doc_values"));
        mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
                .startObject("_timestamp").field("enabled", randomBoolean()).startObject("fielddata").field("loading", "eager").field("format", "array").endObject().field("store", "no").endObject()
                .endObject().endObject();
        PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
        appliedMappings = client().admin().indices().prepareGetMappings("test").get();
        timestampMapping = (LinkedHashMap) appliedMappings.getMappings().get("test").get("type").getSourceAsMap().get("_timestamp");
        assertThat((Boolean) timestampMapping.get("store"), equalTo(false));
        assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("loading"), equalTo("eager"));
        assertThat((String)((LinkedHashMap) timestampMapping.get("fielddata")).get("format"), equalTo("array"));
View Full Code Here

        node.client().admin().indices().prepareCreate("es003index").execute().actionGet();

        XContentBuilder xbMapping = buildMapping();
        logger.info("Mapping is : {}", xbMapping.string());

        PutMappingResponse response = node.client().admin().indices()
            .preparePutMapping("es003index")
            .setType("type1")
            .setSource(xbMapping)
            .execute().actionGet();
        if (!response.isAcknowledged()) {
            throw new Exception("Could not define mapping.");
        }
        node.client().admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();

        node.client().prepareIndex("es003index", "type1").setSource("{\"analyzed\" : \"Abc Def\", \"notanalyzed\" : \"Abc Def\"}").execute().actionGet();
View Full Code Here

        // check mapping again
        assertSizeMappingEnabled(index, type, true);

        // update some field in the mapping
        XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "string").endObject().endObject();
        PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
        assertAcked(putMappingResponse);

        // make sure size field is still in mapping
        assertSizeMappingEnabled(index, type, true);
    }
View Full Code Here

        // check mapping again
        assertSizeMappingEnabled(index, type, true);

        // update some field in the mapping
        XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("_size").field("enabled", false).endObject().endObject();
        PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
        assertAcked(putMappingResponse);

        // make sure size field is still in mapping
        assertSizeMappingEnabled(index, type, false);
    }
View Full Code Here

        // check mapping again
        assertIndexMappingEnabled(index, type);

        // update some field in the mapping
        XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "string").endObject().endObject();
        PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
        assertAcked(putMappingResponse);

        // make sure timestamp field is still in mapping
        assertIndexMappingEnabled(index, type);
    }
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

            // 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

        "image",
        "movie" }) {
      PutMappingRequest siteMappingRequest = new PutMappingRequest(site.getIdentifier());
      siteMappingRequest.source(loadMapping(type));
      siteMappingRequest.type(type);
      PutMappingResponse siteMappingResponse = nodeClient.admin().indices().putMapping(siteMappingRequest).actionGet();
      if (!siteMappingResponse.acknowledged()) {
        throw new ContentRepositoryException("Unable to install '" + type + "' mapping for index '" + site.getIdentifier() + "'");
      }
    }

    // See if the index version exists and check if it matches. The request will
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.