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

Examples of org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest


  public Map getMapping(String indexName, String type) {
    Assert.notNull(indexName, "No index defined for putMapping()");
    Assert.notNull(type, "No type defined for putMapping()");
    Map mappings = null;
    try {
      mappings = client.admin().indices().getMappings(new GetMappingsRequest().indices(indexName).types(type))
          .actionGet().getMappings().get(indexName).get(type).getSourceAsMap();
    } catch (Exception e) {
      throw new ElasticsearchException("Error while getting mapping for indexName : " + indexName + " type : " + type + " " + e.getMessage());
    }
    return mappings;
View Full Code Here


    @Override
    public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
        final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
        final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
        GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
        getMappingsRequest.indices(indices).types(types);
        getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
        getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
        client.admin().indices().getMappings(getMappingsRequest, new RestBuilderListener<GetMappingsResponse>(channel) {
            @Override
            public RestResponse buildResponse(GetMappingsResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsByIndex = response.getMappings();
View Full Code Here

        assertPrecision(new Distance(11, DistanceUnit.METERS));
    }

    private void assertPrecision(Distance expected) throws Exception {
        ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = client().admin().indices().getMappings(new GetMappingsRequest().indices("test").types("type1")).actionGet().getMappings();
        assertNotNull(mappings);
        Map<String, ?> properties = (Map<String, ?>) mappings.get("test").get("type1").getSourceAsMap().get("properties");
        Map<String, ?> pinProperties = (Map<String, ?>) properties.get("pin");
        Map<String, ?> pinFieldData = (Map<String, ?>) pinProperties.get("fielddata");
        Distance precision = Distance.parseDistance(pinFieldData.get("precision").toString());
View Full Code Here

    @Test
    public void testGetMappings() {
        interceptTransportActions(GetMappingsAction.NAME);

        GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(randomIndicesOrAliases());
        internalCluster().clientNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet();

        clearInterceptedActions();
        assertSameIndices(getMappingsRequest, GetMappingsAction.NAME);
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest

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.