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


Java Builder类代码示例

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


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

示例1: initESClient

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
@Bean
public TransportClient initESClient() throws NumberFormatException, UnknownHostException{
	String ip = env.getProperty("spring.es.ip");
	String port = env.getProperty("spring.es.port");
	String clusterName = env.getProperty("spring.es.cluster_name");
	
	Builder builder = Settings.builder().put("cluster.name", clusterName).put("client.transport.sniff", true);
	Settings esSettings = builder.build();
	TransportClient client = new PreBuiltTransportClient(esSettings);
	client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), Integer.parseInt(port)));
	logger.info("ES Client 初始化成功, ip : {}, port : {}, cluster_name : {}", ip, port, clusterName);
	return client;
}
 
开发者ID:SnailFastGo,项目名称:springboot_op,代码行数:14,代码来源:ElasticsearchConfiguration.java

示例2: getSettings

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
private Settings getSettings(int nodeOrdinal, long nodeSeed, Settings others) {
    Builder builder = Settings.builder().put(defaultSettings)
        .put(getRandomNodeSettings(nodeSeed));
    Settings settings = nodeConfigurationSource.nodeSettings(nodeOrdinal);
    if (settings != null) {
        if (settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()) != null) {
            throw new IllegalStateException("Tests must not set a '" + ClusterName.CLUSTER_NAME_SETTING.getKey() + "' as a node setting set '" + ClusterName.CLUSTER_NAME_SETTING.getKey() + "': [" + settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()) + "]");
        }
        builder.put(settings);
    }
    if (others != null) {
        builder.put(others);
    }
    builder.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName);
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InternalTestCluster.java

示例3: indexRandomNumbers

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
private int indexRandomNumbers(String analyzer, int shards, boolean dummyDocs) throws Exception {
    Builder builder = Settings.builder().put(indexSettings());

    if (shards > 0) {
        builder.put(SETTING_NUMBER_OF_SHARDS, shards);
    }

    assertAcked(prepareCreate("test")
            .addMapping(
                    "type1",
                    jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1")
                            .field("analyzer", analyzer).field("type", "text").endObject().endObject().endObject().endObject())
            .setSettings(builder));
    int numDocs = randomIntBetween(100, 150);
    IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs];
    for (int i = 0; i < numDocs; i++) {
        docs[i] = client().prepareIndex("test", "type1", String.valueOf(i)).setSource("field1", English.intToEnglish(i));
    }

    indexRandom(true, dummyDocs, docs);
    ensureGreen();
    return numDocs;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:QueryRescorerIT.java

示例4: testFromSize

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
public void testFromSize() throws Exception {
    Builder settings = Settings.builder();
    settings.put(SETTING_NUMBER_OF_SHARDS, 1);
    settings.put(SETTING_NUMBER_OF_REPLICAS, 0);
    assertAcked(prepareCreate("test").setSettings(settings));
    for(int i=0;i<5;i++) {
        client().prepareIndex("test", "type", ""+i).setSource("text", "hello world").get();
    }
    refresh();

    SearchRequestBuilder request = client().prepareSearch();
    request.setQuery(QueryBuilders.termQuery("text", "hello"));
    request.setFrom(1);
    request.setSize(4);
    request.addRescorer(RescoreBuilder.queryRescorer(QueryBuilders.matchAllQuery()), 50);

    assertEquals(4, request.get().getHits().getHits().length);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:QueryRescorerIT.java

示例5: testBackwardsCompatibilityEdgeNgramTokenFilter

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
public void testBackwardsCompatibilityEdgeNgramTokenFilter() throws Exception {
    int iters = scaledRandomIntBetween(20, 100);
    for (int i = 0; i < iters; i++) {
        final Index index = new Index("test", "_na_");
        final String name = "ngr";
        Version v = randomVersion(random());
        Builder builder = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3);
        boolean reverse = random().nextBoolean();
        if (reverse) {
            builder.put("side", "back");
        }
        Settings settings = builder.build();
        Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build();
        Tokenizer tokenizer = new MockTokenizer();
        tokenizer.setReader(new StringReader("foo bar"));
        TokenStream edgeNGramTokenFilter = new EdgeNGramTokenFilterFactory(IndexSettingsModule.newIndexSettings(index, indexSettings), null, name, settings).create(tokenizer);
        if (reverse) {
            assertThat(edgeNGramTokenFilter, instanceOf(ReverseStringFilter.class));
        } else {
            assertThat(edgeNGramTokenFilter, instanceOf(EdgeNGramTokenFilter.class));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:NGramTokenizerFactoryTests.java

示例6: testCorrectPositionIncrementSetting

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
public void testCorrectPositionIncrementSetting() throws IOException {
    Builder builder = Settings.builder().put("index.analysis.filter.my_stop.type", "stop");
    if (random().nextBoolean()) {
        builder.put("index.analysis.filter.my_stop.version", Version.LATEST);
    } else {
        // don't specify
    }
    builder.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString());
    ESTestCase.TestAnalysis analysis = AnalysisTestsHelper.createTestAnalysisFromSettings(builder.build());
    TokenFilterFactory tokenFilter = analysis.tokenFilter.get("my_stop");
    assertThat(tokenFilter, instanceOf(StopTokenFilterFactory.class));
    Tokenizer tokenizer = new WhitespaceTokenizer();
    tokenizer.setReader(new StringReader("foo bar"));
    TokenStream create = tokenFilter.create(tokenizer);
    assertThat(create, instanceOf(StopFilter.class));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:StopTokenFilterTests.java

示例7: setUp

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
public void setUp(final BiConsumer<Integer, Builder> consumer) throws Exception {
    clusterName = "es-idxproxy-" + System.currentTimeMillis();
    // create runner instance
    runner = new ElasticsearchClusterRunner();
    // create ES nodes
    runner.onBuild((number, settingsBuilder) -> {
        settingsBuilder.put("http.cors.enabled", true);
        settingsBuilder.put("http.cors.allow-origin", "*");
        settingsBuilder.putArray("discovery.zen.ping.unicast.hosts", "127.0.0.1:9301-9310");
        consumer.accept(number, settingsBuilder);
    }).build(newConfigs().clusterName(clusterName).numOfNode(numOfNode)
            .pluginTypes("org.codelibs.elasticsearch.idxproxy.IndexingProxyPlugin"));

    // wait for yellow status
    runner.ensureYellow();
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:17,代码来源:IndexingProxyPluginTest.java

示例8: ElasticNamespaceDAO

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
public ElasticNamespaceDAO(ElasticDAOConfig config) {
	try {
		Builder builder = Settings.builder();
		// Check for new hosts within the cluster
		builder.put(CLIENT_SNIFFING_CONFIG, true);
		// specify cluster name
		if (config.getClusterName() != null) {
			builder.put(CLIENT_CLUSTER_NAME_CONFIG, config.getClusterName());
		}
		Settings settings = builder.build();
		// create client
		elasticClient = new PreBuiltTransportClient(settings);
		// add hosts
		for (String elasticHost : config.getHosts()) {
			elasticClient.addTransportAddress(
					new InetSocketTransportAddress(InetAddress.getByName(elasticHost), config.getPort()));
		}
	} catch (UnknownHostException e) {
		throw new RuntimeException("Unable to initialize Eleasticsearch client " + e.getLocalizedMessage());
	}
}
 
开发者ID:carone1,项目名称:ecs-dashboard,代码行数:22,代码来源:ElasticNamespaceDAO.java

示例9: ElasticVdcDAO

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
public ElasticVdcDAO(ElasticDAOConfig config) {
	try {
		Builder builder = Settings.builder();
		// Check for new hosts within the cluster
		builder.put(CLIENT_SNIFFING_CONFIG, true);
		// specify cluster name
		if (config.getClusterName() != null) {
			builder.put(CLIENT_CLUSTER_NAME_CONFIG, config.getClusterName());
		}
		Settings settings = builder.build();
		// create client
		elasticClient = new PreBuiltTransportClient(settings);
		// add hosts
		for (String elasticHost : config.getHosts()) {
			elasticClient.addTransportAddress(
					new InetSocketTransportAddress(InetAddress.getByName(elasticHost), config.getPort()));
		}
	} catch (UnknownHostException e) {
		throw new RuntimeException("Unable to initialize Eleasticsearch client " + e.getLocalizedMessage());
	}
}
 
开发者ID:carone1,项目名称:ecs-dashboard,代码行数:22,代码来源:ElasticVdcDAO.java

示例10: cleanUpOnce

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
@BeforeClass
public static void cleanUpOnce() throws Exception {
    deleteDirectory("target/testcluster/");
    clusterName = "es-cl-run-" + System.currentTimeMillis();
    // create runner instance
    runner = new ElasticsearchClusterRunner();
    // create ES nodes
    runner.onBuild(new ElasticsearchClusterRunner.Builder() {
        @Override
        public void build(final int number, final Builder settingsBuilder) {
            settingsBuilder.put("http.cors.enabled", true);
            settingsBuilder.put("http.cors.allow-origin", "*");
        }
    }).build(
            newConfigs()
            .clusterName("testCluster")
            .numOfNode(3)
            .basePath("target/testcluster/")
            .useLogger());

    // wait for green status
    runner.ensureGreen();
    
    client = runner.client();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:ElasticsearchClusterBaseTest.java

示例11: applySettings

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
private Builder applySettings() {
    Builder settingsBuilder = Settings.builder();

    settingsBuilder.put("client.transport.ping_timeout", "15s");
    settingsBuilder.put("client.transport.nodes_sampler_interval", "5s");
    // YG: to ensure reliable connection & resolve NoNodeAvailableException
    settingsBuilder.put("client.transport.sniff", true);
    settingsBuilder.put("network.bind_host", 0);

    // YG: for supporting ES Auth with ES Shield
    Optional.ofNullable(config.getElastic().getAuth())
            .ifPresent(auth -> settingsBuilder.put("xpack.security.user", String.join(":", auth.getUser(), auth.getPwd())));

    if (Objects.nonNull(config.getElastic().getClusterName())) {
        settingsBuilder.put("cluster.name", config.getElastic().getClusterName());
    } else {
        settingsBuilder.put("client.transport.ignore_cluster_name", true);
    }
    return settingsBuilder;
}
 
开发者ID:ozlerhakan,项目名称:mongolastic,代码行数:21,代码来源:ElasticConfiguration.java

示例12: setUp

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    clusterName = "es-analyzeapi-" + System.currentTimeMillis();
    // create runner instance
    runner = new ElasticsearchClusterRunner();
    // create ES nodes
    runner.onBuild(new ElasticsearchClusterRunner.Builder() {
        @Override
        public void build(final int number, final Builder settingsBuilder) {
            settingsBuilder.put("http.cors.enabled", true);
            settingsBuilder.put("http.cors.allow-origin", "*");
            settingsBuilder.putArray("discovery.zen.ping.unicast.hosts", "localhost:9301-9310");
        }
    }).build(newConfigs().clusterName(clusterName).numOfNode(numOfNode)
            .pluginTypes("org.codelibs.elasticsearch.analyze.AnalyzeApiPlugin,org.codelibs.elasticsearch.ja.JaPlugin"));

    // wait for yellow status
    runner.ensureYellow();
}
 
开发者ID:codelibs,项目名称:elasticsearch-analyze-api,代码行数:20,代码来源:AnalyzeApiPluginTest.java

示例13: setUp

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    clusterName = "es-analysisja-" + System.currentTimeMillis();
    runner = new ElasticsearchClusterRunner();
    runner.onBuild(new ElasticsearchClusterRunner.Builder() {
        @Override
        public void build(final int number, final Builder settingsBuilder) {
            settingsBuilder.put("http.cors.enabled", true);
            settingsBuilder.put("http.cors.allow-origin", "*");
            settingsBuilder.putList("discovery.zen.ping.unicast.hosts", "localhost:9301-9310");
        }
    }).build(newConfigs().clusterName(clusterName).numOfNode(numOfNode)
            .pluginTypes("org.codelibs.elasticsearch.ja.JaPlugin,"
                    + "org.codelibs.elasticsearch.ja.kuromoji.plugin.analysis.kuromoji.AnalysisKuromojiPlugin"));

    userDictFiles = null;
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-ja,代码行数:18,代码来源:JaPluginTest.java

示例14: setUp

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    clusterName = "es-langfield-" + System.currentTimeMillis();
    // create runner instance
    runner = new ElasticsearchClusterRunner();
    // create ES nodes
    runner.onBuild(new ElasticsearchClusterRunner.Builder() {
        @Override
        public void build(final int number, final Builder settingsBuilder) {
            settingsBuilder.put("http.cors.enabled", true);
            settingsBuilder.put("http.cors.allow-origin", "*");
            settingsBuilder.putList("discovery.zen.ping.unicast.hosts",
                    "localhost:9301-9310");
        }
    }).build(newConfigs().clusterName(clusterName).numOfNode(1).pluginTypes("org.codelibs.elasticsearch.langfield.LangFieldPlugin"));

    // wait for yellow status
    runner.ensureYellow();
}
 
开发者ID:codelibs,项目名称:elasticsearch-langfield,代码行数:20,代码来源:LangFieldPluginTest.java

示例15: setUp

import org.elasticsearch.common.settings.Settings.Builder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    clusterName = "es-kuromojineologd-" + System.currentTimeMillis();
    runner = new ElasticsearchClusterRunner();
    runner.onBuild(new ElasticsearchClusterRunner.Builder() {
        @Override
        public void build(final int number, final Builder settingsBuilder) {
            settingsBuilder.put("http.cors.enabled", true);
            settingsBuilder.put("http.cors.allow-origin", "*");
            settingsBuilder.putList("discovery.zen.ping.unicast.hosts", "localhost:9301-9310");
        }
    }).build(newConfigs().clusterName(clusterName).numOfNode(numOfNode)
            .pluginTypes("org.codelibs.elasticsearch.kuromoji.neologd.KuromojiNeologdPlugin"));

    userDictFiles = null;
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-kuromoji-neologd,代码行数:17,代码来源:KuromojiNeologdPluginTest.java


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