Package org.elasticsearch.cluster.metadata

Examples of org.elasticsearch.cluster.metadata.IndexTemplateMetaData$Builder


                }
            }

            if (request.filteredIndexTemplates().length > 0) {
                for (String templateName : request.filteredIndexTemplates()) {
                    IndexTemplateMetaData indexTemplateMetaData = currentState.metaData().templates().get(templateName);
                    if (indexTemplateMetaData != null) {
                        mdBuilder.put(indexTemplateMetaData);
                    }
                }
            }
View Full Code Here


    @Test
    public void testThatTemplateIsAdded() throws Exception {
        GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("metrics_template").get();

        assertThat(response.getIndexTemplates(), hasSize(1));
        IndexTemplateMetaData templateData = response.getIndexTemplates().get(0);
        assertThat(templateData.order(), is(0));
        assertThat(templateData.getMappings().get("_default_"), is(notNullValue()));
    }
View Full Code Here

        elasticsearchReporter = createElasticsearchReporterBuilder().build();

        GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("metrics_template").get();

        assertThat(response.getIndexTemplates(), hasSize(1));
        IndexTemplateMetaData templateData = response.getIndexTemplates().get(0);
        assertThat(templateData.template(), is("foo*"));
    }
View Full Code Here

        GetIndexTemplatesResponse response = client().admin().indices()
                .prepareGetTemplates(".partitioned.partitioned.").execute().actionGet();

        assertThat(response.getIndexTemplates().size(), is(1));
        IndexTemplateMetaData templateMeta = response.getIndexTemplates().get(0);
        assertThat(templateMeta.getName(), is(".partitioned.partitioned."));
        assertThat(templateMeta.mappings().get(Constants.DEFAULT_MAPPING_TYPE).string(),
                is("{\"default\":" +
                        "{\"properties\":{" +
                        "\"id\":{\"type\":\"integer\",\"store\":false,\"index\":\"not_analyzed\",\"doc_values\":true}," +
                        "\"name\":{\"type\":\"string\",\"store\":false,\"index\":\"not_analyzed\",\"doc_values\":true}," +
                        "\"names\":{\"type\":\"string\",\"store\":false,\"index\":\"not_analyzed\",\"doc_values\":false}" +
                        "}," +
                        "\"_meta\":{" +
                        "\"partitioned_by\":[[\"name\",\"string\"]]" +
                        "}}}"));
        assertThat(templateMeta.template(), is(".partitioned.partitioned.*"));
        assertThat(templateMeta.settings().toDelimitedString(','),
                is("index.number_of_replicas=0,index.number_of_shards=2,"));
        assertThat(templateMeta.aliases().get(alias).alias(), is(alias));
    }
View Full Code Here

        refresh();

        execute("alter table t partition (date='2014-01-01') add name string");

        GetIndexTemplatesResponse templatesResponse = client().admin().indices().getTemplates(new GetIndexTemplatesRequest(".partitioned.t.")).actionGet();
        IndexTemplateMetaData metaData = templatesResponse.getIndexTemplates().get(0);
        String mappingSource = metaData.mappings().get(Constants.DEFAULT_MAPPING_TYPE).toString();
        Map mapping = (Map) XContentFactory.xContent(mappingSource)
                .createParser(mappingSource)
                .mapAndClose()
                .get(Constants.DEFAULT_MAPPING_TYPE);
        assertNull(((Map) mapping.get("properties")).get("name"));

        execute("insert into t (id, date, name) values (2, '2014-01-01', 100)"); // insert integer as name
        refresh();
        execute("select name from t where id = 2 and date = '2014-01-01'");

        assertThat((String) response.rows()[0][0], is("100")); // is returned as string

        execute("alter table t add name2 string"); // now template is also updated
        execute("select * from t");
        assertThat(Arrays.asList(response.cols()), Matchers.contains("date", "id", "name", "name2"));

        templatesResponse = client().admin().indices().getTemplates(new GetIndexTemplatesRequest(".partitioned.t.")).actionGet();
        metaData = templatesResponse.getIndexTemplates().get(0);
        mappingSource = metaData.mappings().get(Constants.DEFAULT_MAPPING_TYPE).toString();
        mapping = (Map) XContentFactory.xContent(mappingSource)
                .createParser(mappingSource)
                .mapAndClose().get(Constants.DEFAULT_MAPPING_TYPE);
        assertNotNull(((Map) mapping.get("properties")).get("name2"));
    }
View Full Code Here

        GetIndexTemplatesResponse response = client().admin().indices()
                .prepareGetTemplates(PartitionName.templateName("numbers"))
                .execute().actionGet();
        assertThat(response.getIndexTemplates().size(), is(1));
        IndexTemplateMetaData template = response.getIndexTemplates().get(0);
        CompressedString mappingStr = template.mappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(mappingStr, is(notNullValue()));
        Tuple<XContentType, Map<String, Object>> typeAndMap = XContentHelper.convertToMap(mappingStr.uncompressed(), false);
        @SuppressWarnings("unchecked")
        Map<String, Object> mapping = (Map<String, Object>)typeAndMap.v2().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(mapping.get("dynamic")), is(ColumnPolicy.STRICT.value()));
View Full Code Here

        GetIndexTemplatesResponse response = client().admin().indices()
                .prepareGetTemplates(PartitionName.templateName("numbers"))
                .execute().actionGet();
        assertThat(response.getIndexTemplates().size(), is(1));
        IndexTemplateMetaData template = response.getIndexTemplates().get(0);
        CompressedString mappingStr = template.mappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(mappingStr, is(notNullValue()));
        Tuple<XContentType, Map<String, Object>> typeAndMap = XContentHelper.convertToMap(mappingStr.uncompressed(), false);
        @SuppressWarnings("unchecked")
        Map<String, Object> mapping = (Map<String, Object>)typeAndMap.v2().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(mapping.get("dynamic")), is(ColumnPolicy.STRICT.value()));
View Full Code Here

        GetIndexTemplatesResponse templateResponse = client().admin().indices()
                .prepareGetTemplates(PartitionName.templateName("numbers"))
                .execute().actionGet();
        assertThat(templateResponse.getIndexTemplates().size(), is(1));
        IndexTemplateMetaData template = templateResponse.getIndexTemplates().get(0);
        CompressedString mappingStr = template.mappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(mappingStr, is(notNullValue()));
        Tuple<XContentType, Map<String, Object>> typeAndMap = XContentHelper.convertToMap(mappingStr.uncompressed(), false);
        @SuppressWarnings("unchecked")
        Map<String, Object> mapping = (Map<String, Object>)typeAndMap.v2().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(mapping.get("dynamic")), is("true"));
View Full Code Here

        ensureGreen();
        GetIndexTemplatesResponse response = client().admin().indices()
                .prepareGetTemplates(PartitionName.templateName("dynamic_table"))
                .execute().actionGet();
        assertThat(response.getIndexTemplates().size(), is(1));
        IndexTemplateMetaData template = response.getIndexTemplates().get(0);
        CompressedString mappingStr = template.mappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(mappingStr, is(notNullValue()));
        Tuple<XContentType, Map<String, Object>> typeAndMap = XContentHelper.convertToMap(mappingStr.uncompressed(), false);
        @SuppressWarnings("unchecked")
        Map<String, Object> mapping = (Map<String, Object>)typeAndMap.v2().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(mapping.get("dynamic")), is(String.valueOf(ColumnPolicy.DYNAMIC.mappingValue())));
View Full Code Here

        assertThat(response.rowCount(), is(1L));
        assertThat((Long) response.rows()[0][0], is(3L));

        GetIndexTemplatesResponse indexTemplatesResponse =
                client().admin().indices().prepareGetTemplates(".partitioned.t.").execute().actionGet();
        IndexTemplateMetaData indexTemplateMetaData = indexTemplatesResponse.getIndexTemplates().get(0);
        AliasMetaData t = indexTemplateMetaData.aliases().get("t");
        assertThat(t.alias(), is("t"));

        execute("select partitioned_by from information_schema.tables where table_name = 't'");
        assertThat(((String[]) response.rows()[0][0])[0], is("p"));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.cluster.metadata.IndexTemplateMetaData$Builder

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.