• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CreateIndexAction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testActions

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
public void testActions() {

        // TODO this is a really shitty way to test it, we need to figure out a way to test all the client methods
        //      without specifying each one (reflection doesn't as each action needs its own special settings, without
        //      them, request validation will fail before the test is executed. (one option is to enable disabling the
        //      validation in the settings??? - ugly and conceptually wrong)

        // choosing arbitrary top level actions to test
        client.prepareGet("idx", "type", "id").execute().addListener(new AssertingActionListener<>(GetAction.NAME, client.threadPool()));
        client.prepareSearch().execute().addListener(new AssertingActionListener<>(SearchAction.NAME, client.threadPool()));
        client.prepareDelete("idx", "type", "id").execute().addListener(new AssertingActionListener<>(DeleteAction.NAME, client.threadPool()));
        client.admin().cluster().prepareDeleteStoredScript("lang", "id").execute().addListener(new AssertingActionListener<>(DeleteStoredScriptAction.NAME, client.threadPool()));
        client.prepareIndex("idx", "type", "id").setSource("source", XContentType.JSON).execute().addListener(new AssertingActionListener<>(IndexAction.NAME, client.threadPool()));

        // choosing arbitrary cluster admin actions to test
        client.admin().cluster().prepareClusterStats().execute().addListener(new AssertingActionListener<>(ClusterStatsAction.NAME, client.threadPool()));
        client.admin().cluster().prepareCreateSnapshot("repo", "bck").execute().addListener(new AssertingActionListener<>(CreateSnapshotAction.NAME, client.threadPool()));
        client.admin().cluster().prepareReroute().execute().addListener(new AssertingActionListener<>(ClusterRerouteAction.NAME, client.threadPool()));

        // choosing arbitrary indices admin actions to test
        client.admin().indices().prepareCreate("idx").execute().addListener(new AssertingActionListener<>(CreateIndexAction.NAME, client.threadPool()));
        client.admin().indices().prepareStats().execute().addListener(new AssertingActionListener<>(IndicesStatsAction.NAME, client.threadPool()));
        client.admin().indices().prepareClearCache("idx1", "idx2").execute().addListener(new AssertingActionListener<>(ClearIndicesCacheAction.NAME, client.threadPool()));
        client.admin().indices().prepareFlush().execute().addListener(new AssertingActionListener<>(FlushAction.NAME, client.threadPool()));
    }
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:AbstractClientHeadersTestCase.java


示例2: newIndex

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
@Override
public BaseMetricTransportClient newIndex(String index, Settings settings, Map<String, String> mappings) {
    if (client == null) {
        logger.warn("no client for create index");
        return this;
    }
    if (index == null) {
        logger.warn("no index name given to create index");
        return this;
    }
    CreateIndexRequestBuilder createIndexRequestBuilder =
            new CreateIndexRequestBuilder(client(), CreateIndexAction.INSTANCE).setIndex(index);
    if (settings != null) {
        logger.info("settings = {}", settings.getAsStructuredMap());
        createIndexRequestBuilder.setSettings(settings);
    }
    if (mappings != null) {
        for (String type : mappings.keySet()) {
            logger.info("found mapping for {}", type);
            createIndexRequestBuilder.addMapping(type, mappings.get(type));
        }
    }
    createIndexRequestBuilder.execute().actionGet();
    logger.info("index {} created", index);
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:27,代码来源:BaseMetricTransportClient.java


示例3: HttpInvoker

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
public HttpInvoker(Settings settings, ThreadPool threadPool, Headers headers, URL url) {
    super(settings, threadPool, headers);
    this.contexts = new HashMap<>();
    this.bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool()));
    bootstrap.setPipelineFactory(new HttpInvoker.HttpClientPipelineFactory());
    bootstrap.setOption("tcpNoDelay", true);

    registerAction(BulkAction.INSTANCE, HttpBulkAction.class);
    registerAction(CreateIndexAction.INSTANCE, HttpCreateIndexAction.class);
    registerAction(RefreshAction.INSTANCE, HttpRefreshIndexAction.class);
    registerAction(ClusterUpdateSettingsAction.INSTANCE, HttpClusterUpdateSettingsAction.class);
    registerAction(UpdateSettingsAction.INSTANCE, HttpUpdateSettingsAction.class);
    registerAction(SearchAction.INSTANCE, HttpSearchAction.class);

    this.url = url;
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:19,代码来源:HttpInvoker.java


示例4: build

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
public HttpElasticsearchClient build() {
    if (url == null && host != null && port != null) {
        try {
            url = new URL("http://" + host + ":" + port);
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("malformed url: " + host + ":" + port);
        }
    }
    if (url == null) {
        throw new IllegalArgumentException("no base URL given");
    }
    ThreadPool threadpool = new ThreadPool("http_client_pool");
    client = new HttpElasticsearchClient(settings, threadpool, Headers.EMPTY, url);

    client.registerAction(BulkAction.INSTANCE, HttpBulkAction.class);
    client.registerAction(CreateIndexAction.INSTANCE, HttpCreateIndexAction.class);
    client.registerAction(RefreshAction.INSTANCE, HttpRefreshIndexAction.class);
    client.registerAction(ClusterUpdateSettingsAction.INSTANCE, HttpClusterUpdateSettingsAction.class);
    client.registerAction(UpdateSettingsAction.INSTANCE, HttpUpdateSettingsAction.class);
    client.registerAction(SearchAction.INSTANCE, HttpSearchAction.class);

    return client;
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:24,代码来源:HttpElasticsearchClient.java


示例5: testOverrideHeader

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
public void testOverrideHeader() throws Exception {
    String key1Val = randomAsciiOfLength(5);
    Map<String, String> expected = new HashMap<>();
    expected.put("key1", key1Val);
    expected.put("key2", "val 2");
    client.threadPool().getThreadContext().putHeader("key1", key1Val);
    client.prepareGet("idx", "type", "id")
            .execute().addListener(new AssertingActionListener<>(GetAction.NAME, expected, client.threadPool()));

    client.admin().cluster().prepareClusterStats()
            .execute().addListener(new AssertingActionListener<>(ClusterStatsAction.NAME, expected, client.threadPool()));

    client.admin().indices().prepareCreate("idx")
            .execute().addListener(new AssertingActionListener<>(CreateIndexAction.NAME, expected, client.threadPool()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:AbstractClientHeadersTestCase.java


示例6: newIndex

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
public HttpBulkClient newIndex(String index, Settings settings, Map<String, String> mappings) {
    if (closed) {
        throw new ElasticsearchException("client is closed");
    }
    if (client == null) {
        logger.warn("no client for create index");
        return this;
    }
    if (index == null) {
        logger.warn("no index name given to create index");
        return this;
    }
    CreateIndexRequestBuilder createIndexRequestBuilder =
            new CreateIndexRequestBuilder(client(), CreateIndexAction.INSTANCE).setIndex(index);
    if (settings != null) {
        logger.info("settings for creating index {} = {}", index, settings.getAsStructuredMap());
        createIndexRequestBuilder.setSettings(settings);
    }
    if (mappings != null) {
        for (Map.Entry<String,String> entry : mappings.entrySet()) {
            String type = entry.getKey();
            logger.info("found mapping for {}", type);
            createIndexRequestBuilder.addMapping(type, entry.getValue());
        }
    }
    createIndexRequestBuilder.execute().actionGet();
    logger.info("index {} created", index);
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:30,代码来源:HttpBulkClient.java


示例7: testSingleDocHttpClient

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
@Test
public void testSingleDocHttpClient() throws Exception {
    try (HttpClient client = HttpClient.builder()
            .url(new URL("http://127.0.0.1:9200"))
            .build()) {
        CreateIndexRequestBuilder createIndexRequestBuilder =
                new CreateIndexRequestBuilder(client, CreateIndexAction.INSTANCE).setIndex("test");
        createIndexRequestBuilder.execute().actionGet();
        IndexRequestBuilder indexRequestBuilder =
                new IndexRequestBuilder(client, IndexAction.INSTANCE)
                        .setIndex("test")
                        .setType("type")
                        .setId("1")
                        .setSource(jsonBuilder().startObject().field("name", "Hello World").endObject());
        indexRequestBuilder.execute().actionGet();
        RefreshRequestBuilder refreshRequestBuilder =
                new RefreshRequestBuilder(client, RefreshAction.INSTANCE)
                        .setIndices("test");
        refreshRequestBuilder.execute().actionGet();
        SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client, SearchAction.INSTANCE)
                .setIndices("test")
                .setQuery(QueryBuilders.matchAllQuery()).setSize(0);
        assertTrue(searchRequestBuilder.execute().actionGet().getHits().getTotalHits() > 0);
    } catch (NoNodeAvailableException e) {
        logger.warn("skipping, no node available");
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:28,代码来源:HttpBulkClientTest.java


示例8: testChineseLanguageCode

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
@Test
public void testChineseLanguageCode() throws Exception {
    startCluster();
    try {
        CreateIndexRequestBuilder createIndexRequestBuilder =
                new CreateIndexRequestBuilder(client(), CreateIndexAction.INSTANCE)
                        .setIndex("test");
        createIndexRequestBuilder.addMapping("someType", jsonBuilder()
                        .startObject()
                          .startObject("properties")
                            .startObject("content")
                              .field("type", "text")
                              .startObject("fields")
                                .startObject("language")
                                   .field("type", "langdetect")
                                   .array("languages", "zh-cn")
                                .endObject()
                              .endObject()
                            .endObject()
                          .endObject()
                        .endObject());
        createIndexRequestBuilder.execute().actionGet();
        IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(client(), IndexAction.INSTANCE)
                .setIndex("test").setType("someType").setId("1")
                .setSource("content", "位于美国首都华盛顿都会圈的希望中文学校5日晚举办活动庆祝建立20周年。从中国大陆留学生为子女学中文而自发建立的学习班,到学生规模在全美名列前茅的中文学校,这个平台的发展也折射出美国的中文教育热度逐步提升。\n" +
                        "希望中文学校是大华盛顿地区最大中文学校,现有7个校区逾4000名学生,规模在美国东部数一数二。不过,见证了希望中文学校20年发展的人们起初根本无法想象这个小小的中文教育平台能发展到今日之规模。");
        indexRequestBuilder.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).execute().actionGet();
        SearchRequestBuilder searchRequestBuilder =
                new SearchRequestBuilder(client(), SearchAction.INSTANCE)
                        .setIndices("test")
                        .setTypes("someType")
                        .setQuery(QueryBuilders.termQuery("content.language", "zh-cn"))
                        .addStoredField("content.language");
        SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
        assertEquals(1L, searchResponse.getHits().getTotalHits());
        assertEquals("zh-cn", searchResponse.getHits().getAt(0).getField("content.language").getValue());
    } finally {
        stopCluster();
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-plugin-bundle,代码行数:41,代码来源:LangDetectChineseTest.java


示例9: testLangDetectBinary

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
@Test
public void testLangDetectBinary() throws Exception {
    startCluster();
    try {
        CreateIndexRequestBuilder createIndexRequestBuilder =
                new CreateIndexRequestBuilder(client(), CreateIndexAction.INSTANCE).setIndex("test");
        createIndexRequestBuilder.addMapping("someType", jsonBuilder()
                 .startObject()
                    .startObject("properties")
                       .startObject("content")
                          .field("type", "text")
                          .startObject("fields")
                             .startObject("language")
                                .field("type", "langdetect")
                                .field("binary", true)
                             .endObject()
                          .endObject()
                       .endObject()
                    .endObject()
                .endObject());
        createIndexRequestBuilder.execute().actionGet();
        IndexRequestBuilder indexRequestBuilder =
                new IndexRequestBuilder(client(), IndexAction.INSTANCE)
                        .setIndex("test").setType("someType").setId("1")
                        //\"God Save the Queen\" (alternatively \"God Save the King\"
                        .setSource("content", "IkdvZCBTYXZlIHRoZSBRdWVlbiIgKGFsdGVybmF0aXZlbHkgIkdvZCBTYXZlIHRoZSBLaW5nIg==");
        indexRequestBuilder.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).execute().actionGet();
        SearchRequestBuilder searchRequestBuilder =
                new SearchRequestBuilder(client(), SearchAction.INSTANCE)
                        .setIndices("test")
                        .setQuery(QueryBuilders.matchAllQuery())
                        .addStoredField("content.language");
        SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
        assertEquals(1L, searchResponse.getHits().getTotalHits());
        assertEquals("en", searchResponse.getHits().getAt(0).getField("content.language").getValue());
    } finally {
        stopCluster();
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-plugin-bundle,代码行数:40,代码来源:LangDetectBinaryTest.java


示例10: newIndex

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
@Override
public BulkNodeClient newIndex(String index, Settings settings, Map<String, String> mappings) {
    if (closed) {
        throw new ElasticsearchException("client is closed");
    }
    if (client == null) {
        logger.warn("no client for create index");
        return this;
    }
    if (index == null) {
        logger.warn("no index name given to create index");
        return this;
    }
    CreateIndexRequestBuilder createIndexRequestBuilder =
            new CreateIndexRequestBuilder(client(), CreateIndexAction.INSTANCE).setIndex(index);
    if (settings != null) {
        logger.info("settings = {}", settings.getAsStructuredMap());
        createIndexRequestBuilder.setSettings(settings);
    }
    if (mappings != null) {
        for (String type : mappings.keySet()) {
            logger.info("found mapping for {}", type);
            createIndexRequestBuilder.addMapping(type, mappings.get(type));
        }
    }
    createIndexRequestBuilder.execute().actionGet();
    logger.info("index {} created", index);
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:30,代码来源:BulkNodeClient.java


示例11: newIndex

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
@Override
public HttpBulkNodeClient newIndex(String index, Settings settings, Map<String, String> mappings) {
    if (closed) {
        throw new ElasticsearchException("client is closed");
    }
    if (client == null) {
        logger.warn("no client for create index");
        return this;
    }
    if (index == null) {
        logger.warn("no index name given to create index");
        return this;
    }
    CreateIndexRequestBuilder createIndexRequestBuilder =
            new CreateIndexRequestBuilder(client(), CreateIndexAction.INSTANCE).setIndex(index);
    if (settings != null) {
        logger.info("settings = {}", settings.getAsStructuredMap());
        createIndexRequestBuilder.setSettings(settings);
    }
    if (mappings != null) {
        for (String type : mappings.keySet()) {
            logger.info("found mapping for {}", type);
            createIndexRequestBuilder.addMapping(type, mappings.get(type));
        }
    }
    createIndexRequestBuilder.execute().actionGet();
    logger.info("index {} created", index);
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:30,代码来源:HttpBulkNodeClient.java


示例12: create

import org.elasticsearch.action.admin.indices.create.CreateIndexAction; //导入依赖的package包/类
@Override
public ActionFuture<CreateIndexResponse> create(final CreateIndexRequest request) {
    return execute(CreateIndexAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java


示例13: prepareCreate

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


示例14: getAction

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BasicHDU类代码示例发布时间:2022-05-23
下一篇:
Java Compression类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap