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


Java PutMappingRequest类代码示例

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


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

示例1: initializeAdditionalMappings

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
    similarity = randomFrom("classic", "BM25");
    mapperService.merge(PARENT_TYPE, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(PARENT_TYPE,
            STRING_FIELD_NAME, "type=text",
            STRING_FIELD_NAME_2, "type=keyword",
            INT_FIELD_NAME, "type=integer",
            DOUBLE_FIELD_NAME, "type=double",
            BOOLEAN_FIELD_NAME, "type=boolean",
            DATE_FIELD_NAME, "type=date",
            OBJECT_FIELD_NAME, "type=object"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
    mapperService.merge(CHILD_TYPE, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(CHILD_TYPE,
            "_parent", "type=" + PARENT_TYPE,
            STRING_FIELD_NAME, "type=text",
            "custom_string", "type=text,similarity=" + similarity,
            INT_FIELD_NAME, "type=integer",
            DOUBLE_FIELD_NAME, "type=double",
            BOOLEAN_FIELD_NAME, "type=boolean",
            DATE_FIELD_NAME, "type=date",
            OBJECT_FIELD_NAME, "type=object"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:HasChildQueryBuilderTests.java

示例2: testDisabledFieldNamesField

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
public void testDisabledFieldNamesField() throws Exception {
    QueryShardContext context = createShardContext();
    context.getMapperService().merge("new_type",
        new CompressedXContent(
            PutMappingRequest.buildFromSimplifiedDef("new_type",
                "foo", "type=text",
                "_field_names", "enabled=false").string()),
        MapperService.MergeReason.MAPPING_UPDATE, true);
    QueryStringQueryBuilder queryBuilder = new QueryStringQueryBuilder("foo:*");
    Query query = queryBuilder.toQuery(context);
    Query expected = new WildcardQuery(new Term("foo", "*"));
    assertThat(query, equalTo(expected));
    context.getMapperService().merge("new_type",
        new CompressedXContent(
            PutMappingRequest.buildFromSimplifiedDef("new_type",
                "foo", "type=text",
                "_field_names", "enabled=true").string()),
        MapperService.MergeReason.MAPPING_UPDATE, true);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:QueryStringQueryBuilderTests.java

示例3: initializeAdditionalMappings

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
    mapperService.merge(PARENT_TYPE, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(PARENT_TYPE,
            STRING_FIELD_NAME, "type=text",
            INT_FIELD_NAME, "type=integer",
            DOUBLE_FIELD_NAME, "type=double",
            BOOLEAN_FIELD_NAME, "type=boolean",
            DATE_FIELD_NAME, "type=date",
            OBJECT_FIELD_NAME, "type=object"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
    mapperService.merge(CHILD_TYPE, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(CHILD_TYPE,
            "_parent", "type=" + PARENT_TYPE,
            STRING_FIELD_NAME, "type=text",
            INT_FIELD_NAME, "type=integer",
            DOUBLE_FIELD_NAME, "type=double",
            BOOLEAN_FIELD_NAME, "type=boolean",
            DATE_FIELD_NAME, "type=date",
            OBJECT_FIELD_NAME, "type=object"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ParentIdQueryBuilderTests.java

示例4: initializeAdditionalMappings

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
    mapperService.merge(PARENT_TYPE, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(PARENT_TYPE,
            STRING_FIELD_NAME, "type=text",
            STRING_FIELD_NAME_2, "type=keyword",
            INT_FIELD_NAME, "type=integer",
            DOUBLE_FIELD_NAME, "type=double",
            BOOLEAN_FIELD_NAME, "type=boolean",
            DATE_FIELD_NAME, "type=date",
            OBJECT_FIELD_NAME, "type=object"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
    mapperService.merge(CHILD_TYPE, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(CHILD_TYPE,
            "_parent", "type=" + PARENT_TYPE,
            STRING_FIELD_NAME, "type=text",
            STRING_FIELD_NAME_2, "type=keyword",
            INT_FIELD_NAME, "type=integer",
            DOUBLE_FIELD_NAME, "type=double",
            BOOLEAN_FIELD_NAME, "type=boolean",
            DATE_FIELD_NAME, "type=date",
            OBJECT_FIELD_NAME, "type=object"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
    mapperService.merge("just_a_type", new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef("just_a_type"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:HasParentQueryBuilderTests.java

示例5: internalPutMapping

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
private static PutMappingResponse internalPutMapping(Client client, String indexName, IElasticSearchMapping mapping) throws IOException {

        final PutMappingRequest putMappingRequest = new PutMappingRequest(indexName)
                .type(mapping.getIndexType())
                .source(mapping.getMapping().string());

        final PutMappingResponse putMappingResponse = client
                .admin()
                .indices()
                .putMapping(putMappingRequest)
                .actionGet();

        if(log.isDebugEnabled()) {
            log.debug("PutMappingResponse: isAcknowledged {}", putMappingResponse.isAcknowledged());
        }

        return putMappingResponse;
    }
 
开发者ID:bytefish,项目名称:ElasticUtils,代码行数:19,代码来源:ElasticSearchUtils.java

示例6: zkfc

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
private static SearchResponse zkfc(String indexName, String zkType, TransportClient client) throws IOException {
    //返回一个可以执行管理性操作的客户端
    //1) cluster(),产生一个允许从集群中执行action或操作的client;
    //2) indices(),产生一个允许从索引中执行action或操作的client。
    //创建zk分词
    PutMappingRequest mapping = Requests.putMappingRequest(indexName).type(zkType).source(createIKMapping(zkType).string());
    client.admin().indices().putMapping(mapping).actionGet();
    Goods goodsOne= new Goods( 1,"iphone7 iphone7plus 钢化膜 玻璃膜 苹果 苹果7/7plus 贴膜 买就送清水","http://m.ule.com/item/detail/1771161");
    Goods goodsTwo=new Goods( 2,"苹果 (Apple) iPhone 7 移动联通电信4G手机 土豪金 32G 标配","http://m.ule.com/item/detail/1799356");
    Goods goodsThree=new Goods( 3,"苹果 Apple iPhone 7 (A1660) 128G 金色 移动联通电信 全网通 4G手机","http://m.ule.com/item/detail/1781429");
    client.prepareIndex(indexName,zkType).setId(1+"").setSource(JSONObject.toJSONString(goodsOne)).execute().actionGet();
    client.prepareIndex(indexName,zkType).setId(2+"").setSource(JSONObject.toJSONString(goodsTwo)).execute().actionGet();
    client.prepareIndex(indexName,zkType).setId(3+"").setSource(JSONObject.toJSONString(goodsThree)).execute().actionGet();

    SearchResponse response = client.prepareSearch(indexName)
            .setTypes(zkType)
            .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
            .setQuery( QueryBuilders.matchQuery("title", "苹果")
            ).execute().actionGet();
    return response;
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:22,代码来源:SearchDemo.java

示例7: initCluster

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@BeforeClass
public void initCluster() throws IOException {
	client = getClient();

	CreateIndexRequest indexRequest = new CreateIndexRequest(INDEX_NAME);
	assertTrue(client.admin().indices().create(indexRequest).actionGet().isAcknowledged());

	String mapping = ResourceUtils.asString("mapping_request.json");
	PutMappingRequestBuilder builder = new PutMappingRequestBuilder(client, PutMappingAction.INSTANCE);
	PutMappingRequest request = builder.setIndices(INDEX_NAME).setType(INDEX_TYPE).setSource(mapping).request();
	assertTrue(client.admin().indices().putMapping(request).actionGet().isAcknowledged());

	String doc01 = ResourceUtils.asString("documents/doc01.json");
	String doc02 = ResourceUtils.asString("documents/doc02.json");
	IndexRequestBuilder indexBuilder = new IndexRequestBuilder(client, IndexAction.INSTANCE, INDEX_NAME).setType(INDEX_TYPE);
	assertTrue(client.index(indexBuilder.setId("1").setSource(doc01).request()).actionGet().isCreated());
	assertTrue(client.index(indexBuilder.setId("2").setSource(doc02).request()).actionGet().isCreated());
	client.admin().indices().flush(new FlushRequest(INDEX_NAME)).actionGet();
	defaultProperties = new DefaultProperties("default.properties");

}
 
开发者ID:kucera-jan-cz,项目名称:esBench,代码行数:22,代码来源:ConfigurationAnalyzerIntegrationTest.java

示例8: initCluster

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@BeforeClass
public void initCluster() throws IOException {
	client = getClient();

	CreateIndexRequest indexRequest = new CreateIndexRequest(INDEX_NAME);
	assertTrue(client.admin().indices().create(indexRequest).actionGet().isAcknowledged());
	String mapping = ResourceUtils.asString("mapping_request.json");
	PutMappingRequestBuilder builder = new PutMappingRequestBuilder(client, PutMappingAction.INSTANCE);
	PutMappingRequest request = builder.setIndices(INDEX_NAME).setType(INDEX_TYPE).setSource(mapping).request();
	assertTrue(client.admin().indices().putMapping(request).actionGet().isAcknowledged());

	String doc01 = ResourceUtils.asString("documents/doc01.json");
	String doc02 = ResourceUtils.asString("documents/doc02.json");
	IndexRequestBuilder indexBuilder = new IndexRequestBuilder(client, IndexAction.INSTANCE, INDEX_NAME).setType(INDEX_TYPE);
	assertTrue(client.index(indexBuilder.setId("1").setSource(doc01).request()).actionGet().isCreated());
	assertTrue(client.index(indexBuilder.setId("2").setSource(doc02).request()).actionGet().isCreated());
	client.admin().indices().flush(new FlushRequest(INDEX_NAME)).actionGet();
	defaultProperties = new DefaultProperties("default.properties");
}
 
开发者ID:kucera-jan-cz,项目名称:esBench,代码行数:20,代码来源:StatsCollectorIntegrationTest.java

示例9: executeBlocking

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
private void executeBlocking(final ActionRequest action) {
    try {
        if (action instanceof PutMappingRequest) {
            getDataContext().getElasticSearchClient().createMapping((PutMappingRequest) action);
        } else {
            final ActionResponse result = getDataContext().getElasticSearchClient().execute(action);

            if (result instanceof BulkResponse && ((BulkResponse) result).hasFailures()) {
                BulkItemResponse[] failedItems = ((BulkResponse) result).getItems();
                for (int i = 0; i < failedItems.length; i++) {
                    if (failedItems[i].isFailed()) {
                        final BulkItemResponse failedItem = failedItems[i];
                        logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i + 1,
                                failedItems.length, failedItem.getId(), failedItem.getOpType(), failedItem.status(),
                                failedItem.getFailureMessage());
                    }
                }
            }
        }
    } catch (IOException e) {
        logger.warn("Could not execute command {} ", action, e);
        throw new MetaModelException("Could not execute " + action, e);
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:25,代码来源:ElasticSearchRestUpdateCallback.java

示例10: testCreateMapping

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Test
public void testCreateMapping() throws Exception {
    PutMappingRequest putMappingRequest = new PutMappingRequest();
    putMappingRequest.indices("blog");
    putMappingRequest.type("");
    client.admin().indices().putMapping(putMappingRequest);
}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:8,代码来源:IndexDemo.java

示例11: initializeAdditionalMappings

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
    queryField = randomAsciiOfLength(4);
    docType = randomAsciiOfLength(4);
    mapperService.merge("query_type", new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef("query_type",
            queryField, "type=percolator"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
    mapperService.merge(docType, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(docType,
            STRING_FIELD_NAME, "type=text"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:PercolateQueryBuilderTests.java

示例12: prepareRequest

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index")));
    putMappingRequest.type(request.param("type"));
    putMappingRequest.source(request.content(), request.getXContentType());
    putMappingRequest.updateAllTypes(request.paramAsBoolean("update_all_types", false));
    putMappingRequest.timeout(request.paramAsTime("timeout", putMappingRequest.timeout()));
    putMappingRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putMappingRequest.masterNodeTimeout()));
    putMappingRequest.indicesOptions(IndicesOptions.fromRequest(request, putMappingRequest.indicesOptions()));
    return channel -> client.admin().indices().putMapping(putMappingRequest, new AcknowledgedRestListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:RestPutMappingAction.java

示例13: initializeAdditionalMappings

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
    mapperService.merge("nested_doc", new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef("nested_doc",
            STRING_FIELD_NAME, "type=text",
            INT_FIELD_NAME, "type=integer",
            DOUBLE_FIELD_NAME, "type=double",
            BOOLEAN_FIELD_NAME, "type=boolean",
            DATE_FIELD_NAME, "type=date",
            OBJECT_FIELD_NAME, "type=object",
            GEO_POINT_FIELD_NAME, "type=geo_point",
            "nested1", "type=nested"
    ).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:NestedQueryBuilderTests.java

示例14: testPutMapping

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
public void testPutMapping() {
    interceptTransportActions(PutMappingAction.NAME);

    PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases())
            .type("type")
            .source("field", "type=text");
    internalCluster().coordOnlyNodeClient().admin().indices().putMapping(putMappingRequest).actionGet();

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

示例15: handleRequest

import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index")));
    putMappingRequest.type(request.param("type"));
    putMappingRequest.source(request.content().toUtf8());
    putMappingRequest.updateAllTypes(request.paramAsBoolean("update_all_types", false));
    putMappingRequest.reindex(request.paramAsBoolean("reindex", false));
    putMappingRequest.timeout(request.paramAsTime("timeout", putMappingRequest.timeout()));
    putMappingRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putMappingRequest.masterNodeTimeout()));
    putMappingRequest.indicesOptions(IndicesOptions.fromRequest(request, putMappingRequest.indicesOptions()));
    client.admin().indices().putMapping(putMappingRequest, new AcknowledgedRestListener<PutMappingResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:RestPutMappingAction.java


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