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

Examples of org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse.mappings()


        ensureGreen();

        client().prepareIndex("test", "type1").setSource("field1", "value1");

        GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("test").addTypes("type1").get();
        assertThat(getMappingsResponse.mappings().get("test").get("type1"), notNullValue());

        assertAcked(client().admin().indices().prepareDeleteMapping("test").setType("type1"));

        for (Client client : clients()) {
            getMappingsResponse = client.admin().indices().prepareGetMappings("test").addTypes("type1").setLocal(true).get();
View Full Code Here


        assertAcked(client().admin().indices().prepareDeleteMapping("test").setType("type1"));

        for (Client client : clients()) {
            getMappingsResponse = client.admin().indices().prepareGetMappings("test").addTypes("type1").setLocal(true).get();
            assertThat(getMappingsResponse.mappings().size(), equalTo(0));
        }
    }

    @Test
    public void testDeleteMappingNoAcknowledgement() {
View Full Code Here

            try (Node node = NodeBuilder.nodeBuilder().local(true).data(true).settings(settings).build()) {
                node.start();

                assertAcked(node.client().admin().indices().prepareCreate("index").addMapping("type", "h", "type=string").get());
                final GetMappingsResponse response = node.client().admin().indices().prepareGetMappings("index").get();
                assertTrue(response.mappings().toString(), response.mappings().containsKey("index"));
                MappingMetaData mappings = response.mappings().get("index").get("type");
                assertNotNull(mappings);
                Map<?, ?> properties = (Map<?, ?>) (mappings.getSourceAsMap().get("properties"));
                assertNotNull(properties);
                assertEquals(ImmutableSet.of("f", "g", "h"), properties.keySet());
View Full Code Here

            try (Node node = NodeBuilder.nodeBuilder().local(true).data(true).settings(settings).build()) {
                node.start();

                assertAcked(node.client().admin().indices().prepareCreate("index").addMapping("type", "h", "type=string").get());
                final GetMappingsResponse response = node.client().admin().indices().prepareGetMappings("index").get();
                assertTrue(response.mappings().toString(), response.mappings().containsKey("index"));
                MappingMetaData mappings = response.mappings().get("index").get("type");
                assertNotNull(mappings);
                Map<?, ?> properties = (Map<?, ?>) (mappings.getSourceAsMap().get("properties"));
                assertNotNull(properties);
                assertEquals(ImmutableSet.of("f", "g", "h"), properties.keySet());
View Full Code Here

                node.start();

                assertAcked(node.client().admin().indices().prepareCreate("index").addMapping("type", "h", "type=string").get());
                final GetMappingsResponse response = node.client().admin().indices().prepareGetMappings("index").get();
                assertTrue(response.mappings().toString(), response.mappings().containsKey("index"));
                MappingMetaData mappings = response.mappings().get("index").get("type");
                assertNotNull(mappings);
                Map<?, ?> properties = (Map<?, ?>) (mappings.getSourceAsMap().get("properties"));
                assertNotNull(properties);
                assertEquals(ImmutableSet.of("f", "g", "h"), properties.keySet());
            }
View Full Code Here

            client().admin().indices().prepareCreate("my-index")
                .addMapping("my-type", createTypeSource())
        );

        GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
        MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
        assertThat(mappingMetaData, not(nullValue()));
        Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
        Map titleFields = ((Map) XContentMapValues.extractValue("properties.title.fields", mappingSource));
        assertThat(titleFields.size(), equalTo(1));
        assertThat(titleFields.get("not_analyzed"), notNullValue());
View Full Code Here

                        .setSource(createPutMappingSource())
                        .setIgnoreConflicts(true) // If updated with multi-field type, we need to ignore failures.
        );

        getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
        mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
        assertThat(mappingMetaData, not(nullValue()));
        mappingSource = mappingMetaData.sourceAsMap();
        assertThat(((Map) XContentMapValues.extractValue("properties.title", mappingSource)).size(), equalTo(2));
        titleFields = ((Map) XContentMapValues.extractValue("properties.title.fields", mappingSource));
        assertThat(titleFields.size(), equalTo(2));
View Full Code Here

                client().admin().indices().prepareCreate("my-index")
                        .addMapping("my-type", createMappingSource("geo_point"))
        );

        GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
        MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
        assertThat(mappingMetaData, not(nullValue()));
        Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
        Map aField = ((Map) XContentMapValues.extractValue("properties.a", mappingSource));
        assertThat(aField.size(), equalTo(2));
        assertThat(aField.get("type").toString(), equalTo("geo_point"));
View Full Code Here

                                .endObject()
                                .endObject().endObject())
        );

        GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
        MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
        assertThat(mappingMetaData, not(nullValue()));
        Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
        Map aField = ((Map) XContentMapValues.extractValue("properties.a", mappingSource));
        assertThat(aField.size(), equalTo(3));
        assertThat(aField.get("type").toString(), equalTo("token_count"));
View Full Code Here

                client().admin().indices().prepareCreate("my-index")
                        .addMapping("my-type", createMappingSource("completion"))
        );

        GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
        MappingMetaData mappingMetaData = getMappingsResponse.mappings().get("my-index").get("my-type");
        assertThat(mappingMetaData, not(nullValue()));
        Map<String, Object> mappingSource = mappingMetaData.sourceAsMap();
        Map aField = ((Map) XContentMapValues.extractValue("properties.a", mappingSource));
        assertThat(aField.size(), equalTo(7));
        assertThat(aField.get("type").toString(), equalTo("completion"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.