Package org.elasticsearch.cluster.metadata

Examples of org.elasticsearch.cluster.metadata.MappingMetaData$ParseContext


    public static String getMapping(String indexName, String indexType) {
        ClusterState state = IndexClient.client.admin().cluster()
                .prepareState()
                .setIndices(IndexService.INDEX_DEFAULT)
                .execute().actionGet().getState();
        MappingMetaData mappingMetaData = state.getMetaData().index(indexName).mapping(indexType);
        if (mappingMetaData != null) {
            return mappingMetaData.source().toString();
        } else {
            return null;
        }
    }
View Full Code Here


                .put("index.number_of_replicas", 0)
                .put(settings);

        IndexMetaData.Builder mdBuilder = IndexMetaData.builder(indexName)
                .settings(settingsBuilder)
                .putMapping(new MappingMetaData(Constants.DEFAULT_MAPPING_TYPE, mappingSource));
        if (aliasMetaData != null) {
            mdBuilder.putAlias(aliasMetaData);
        }
        return mdBuilder.build();
    }
View Full Code Here

                .put(analysis.tableParameter().settings());

        analyzer.process(statement, analysis);
        IndexMetaData indexMetaData = IndexMetaData.builder(analysis.tableIdent().name())
                .settings(settingsBuilder)
                .putMapping(new MappingMetaData(Constants.DEFAULT_MAPPING_TYPE, analysis.mapping()))
                .build();

        return newMeta(indexMetaData, analysis.tableIdent().name());
    }
View Full Code Here

        execute("insert into numbers (num, odd, prime) values (?, ?, ?)",
                new Object[]{6, true, false});
        execute("refresh table numbers");

        MappingMetaData partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("numbers", Arrays.asList(new BytesRef("true"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(ColumnPolicy.STRICT.value()));

        expectedException.expect(SQLActionException.class);
        expectedException.expectMessage("Column 'perfect' unknown");
        execute("insert into numbers (num, odd, prime, perfect) values (?, ?, ?, ?)",
                new Object[]{28, true, false, true});
View Full Code Here

        execute("insert into numbers (num, odd, prime) values (?, ?, ?)",
                new Object[]{6, true, false});
        execute("refresh table numbers");

        MappingMetaData partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("numbers", Arrays.asList(new BytesRef("true"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(ColumnPolicy.STRICT.value()));

        expectedException.expect(SQLActionException.class);
        expectedException.expectMessage("Column 'perfect' unknown");
        execute("update numbers set num=?, perfect=? where num=6",
                new Object[]{28, true});
View Full Code Here

        execute("insert into numbers (num, odd, prime) values (?, ?, ?)",
                new Object[]{6, true, false});
        execute("refresh table numbers");

        MappingMetaData partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("numbers", Arrays.asList(new BytesRef("true"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is("true"));

        execute("insert into numbers (num, odd, prime, perfect) values (?, ?, ?, ?)",
                new Object[]{28, true, false, true});
        ensureGreen();
        execute("refresh table numbers");
View Full Code Here

                "  score double" +
                ") with (number_of_replicas=0)");
        ensureGreen();
        execute("alter table dynamic_table set (column_policy = 'strict')");
        waitNoPendingTasksOnAll();
        MappingMetaData partitionMetaData = clusterService().state().metaData().indices()
                .get("dynamic_table")
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(ColumnPolicy.STRICT.value()));
        execute("alter table dynamic_table reset (column_policy)");
        waitNoPendingTasksOnAll();
        partitionMetaData = clusterService().state().metaData().indices()
                .get("dynamic_table")
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(String.valueOf(ColumnPolicy.DYNAMIC.mappingValue())));
    }
View Full Code Here

        ensureGreen();
        execute("insert into dynamic_table (id, score) values (1, 10)");
        execute("refresh table dynamic_table");
        execute("alter table dynamic_table set (column_policy = 'strict')");
        waitNoPendingTasksOnAll();
        MappingMetaData partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("dynamic_table", Arrays.asList(new BytesRef("10.0"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(ColumnPolicy.STRICT.value()));
        execute("alter table dynamic_table reset (column_policy)");
        waitNoPendingTasksOnAll();
        partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("dynamic_table", Arrays.asList(new BytesRef("10.0"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(String.valueOf(ColumnPolicy.DYNAMIC.mappingValue())));
    }
View Full Code Here

        execute("insert into dynamic_table (id, score, new_col) values (?, ?, ?)",
                new Object[]{6, 3, "hello"});
        execute("refresh table dynamic_table");
        ensureGreen();

        MappingMetaData partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("dynamic_table", Arrays.asList(new BytesRef("10.0"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(String.valueOf(ColumnPolicy.DYNAMIC.mappingValue())));

        partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("dynamic_table", Arrays.asList(new BytesRef("5.0"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(String.valueOf(ColumnPolicy.DYNAMIC.mappingValue())));

        partitionMetaData = clusterService().state().metaData().indices()
                .get(new PartitionName("dynamic_table", Arrays.asList(new BytesRef("3.0"))).stringValue())
                .getMappings().get(Constants.DEFAULT_MAPPING_TYPE);
        assertThat(String.valueOf(partitionMetaData.getSourceAsMap().get("dynamic")), is(String.valueOf(ColumnPolicy.DYNAMIC.mappingValue())));
    }
View Full Code Here

  @Test
  public void test_merge_mapping() throws IOException {
    Client client = checkClient("esClient");
    checkClient("esClient2");

        MappingMetaData response = client.admin().indices().prepareGetMappings().get().getMappings().get("twitter").get("tweet");
        String mapping = new String(response.source().uncompressed());
        // This one comes from the first mapping
        assertThat(mapping, containsString("message"));
        // This one comes from the second mapping
        assertThat(mapping, containsString("author"));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.cluster.metadata.MappingMetaData$ParseContext

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.