当前位置: 首页>>代码示例>>Java>>正文


Java GetMappingsAction类代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction的典型用法代码示例。如果您正苦于以下问题:Java GetMappingsAction类的具体用法?Java GetMappingsAction怎么用?Java GetMappingsAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GetMappingsAction类属于org.elasticsearch.action.admin.indices.mapping.get包,在下文中一共展示了GetMappingsAction类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIngestCreation

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Test
public void testIngestCreation() throws Exception {
    Settings settingsForIndex = Settings.settingsBuilder()
            .put("index.number_of_shards", 1)
            .build();
    Map<String,String> mappings = new HashMap<>();
    mappings.put("typename","{\"properties\":{\"message\":{\"type\":\"string\"}}}");
    final IngestTransportClient ingest = ClientBuilder.builder()
            .put(getSettings())
            .setMetric(new LongAdderIngestMetric())
            .toIngestTransportClient();
    try {
        ingest.newIndex("test", settingsForIndex, mappings);
        GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices("test");
        GetMappingsResponse getMappingsResponse =
                ingest.client().execute(GetMappingsAction.INSTANCE, getMappingsRequest).actionGet();
        MappingMetaData md = getMappingsResponse.getMappings().get("test").get("typename");
        assertEquals("{properties={message={type=string}}}", md.getSourceAsMap().toString());
    } finally {
        ingest.shutdown();
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:23,代码来源:IngestIndexCreationTest.java

示例2: testGetMappings

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
public void testGetMappings() {
    interceptTransportActions(GetMappingsAction.NAME);

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

    clearInterceptedActions();
    assertSameIndices(getMappingsRequest, GetMappingsAction.NAME);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:IndicesRequestIT.java

示例3: getAllMappings

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ImmutableOpenMap<String, MappingMetaData> getAllMappings(String index) {
    Object mapping = cache.get(makeKey(index));
    if (mapping == null) {
        mapping = new GetMappingsRequestBuilder(getClient(), GetMappingsAction.INSTANCE, index)
                .get().mappings().get(index);
        cache.put(makeKey(index), mapping);
    }
    return (ImmutableOpenMap<String, MappingMetaData>) mapping;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:12,代码来源:DefaultMetaDataProvider.java

示例4: insertSchema

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Test
public void insertSchema() throws Exception {
    sink.prepare(mapping);

    IndicesAdminClient indicesClient = sink.getClient().admin().indices();
    GetMappingsRequestBuilder builder = new GetMappingsRequestBuilder(indicesClient, GetMappingsAction.INSTANCE, mapping.getIndex())
            .addTypes(mapping.getType());
    GetMappingsResponse response = indicesClient.getMappings(builder.request()).actionGet();
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = response.getMappings();

    Map<String, Object> recordTypeMap = mappings.get(mapping.getIndex()).get(mapping.getType()).getSourceAsMap();
    assertThat("dynamic value is correct", Boolean.valueOf(recordTypeMap.get("dynamic").toString()), is(mapping.isDynamicMappingEnabled()));

    Thread.sleep(1000);

    // https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html
    String allMappingsResponse = Request
            .Get("http://localhost:9200/_mapping/_all?pretty").execute()
            .returnContent().asString();
    assertThat("record type is provided (checking id property type", allMappingsResponse, hasJsonPath(mapping.getIndex() + ".mappings." + mapping.getType() + ".properties.id.type", is("string")));
    assertThat("metadata type is provided (checking mt_update-time property type)", allMappingsResponse, hasJsonPath(mapping.getIndex() + ".mappings.mt.properties.mt-update-time.type", is("date")));

    // https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html
    StatusLine recordsStatus = Request
            .Head("http://localhost:9200/" + mapping.getIndex() + "/" + mapping.getType()).execute()
            .returnResponse().getStatusLine();
    assertThat("records type is available", recordsStatus.getStatusCode(), is(200));
    StatusLine mtStatus = Request
            .Head("http://localhost:9200/" + mapping.getIndex() + "/mt").execute()
            .returnResponse().getStatusLine();
    assertThat("metadata type is available", mtStatus.getStatusCode(), is(200));
}
 
开发者ID:52North,项目名称:youngs,代码行数:33,代码来源:ElasticsearchSinkTestmappingIT.java

示例5: getDynamicFieldNames

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Override
public List<String> getDynamicFieldNames() throws SearchEngineException {
	List<String> fieldNames = new LinkedList<>();

	try {
		GetMappingsRequest req =
				new GetMappingsRequestBuilder(client, GetMappingsAction.INSTANCE, configuration.getIndexName())
						.setTypes(configuration.getDocType())
						.request();
		GetMappingsResponse response = client.admin().indices().getMappings(req).actionGet();
		MappingMetaData metaData = response.getMappings()
				.get(configuration.getIndexName())
				.get(configuration.getDocType());
		Map<String, Object> sourceMap = metaData.getSourceAsMap();
		Object annotationField = ((Map)sourceMap.get("properties")).get(configuration.getAnnotationField());
		Map<String, Object> annotationProperties = (Map<String, Object>)((Map)annotationField).get("properties");

		if (annotationProperties != null) {
			for (String field : annotationProperties.keySet()) {
				if (field.matches(DYNAMIC_LABEL_FIELD_REGEX)) {
					fieldNames.add(field);
				}
			}
		}
	} catch (IOException e) {
		LOGGER.error("Caught IOException retrieving field source: {}", e.getMessage());
		throw new SearchEngineException(e);
	}

	return fieldNames;
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:32,代码来源:ElasticSearchEngine.java

示例6: getMappings

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Override
public void getMappings(GetMappingsRequest request, ActionListener<GetMappingsResponse> listener) {
    execute(GetMappingsAction.INSTANCE, request, listener);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例7: prepareGetMappings

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
@Override
public GetMappingsRequestBuilder prepareGetMappings(String... indices) {
    return new GetMappingsRequestBuilder(this, GetMappingsAction.INSTANCE, indices);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例8: getAction

import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; //导入依赖的package包/类
public GetMappingsAction getAction() {
    return GetMappingsAction.INSTANCE;
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:4,代码来源:GetMappingsActionHandler.java


注:本文中的org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。