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


Java Settings类代码示例

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


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

示例1: jsonquery

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
/**
 * json查询
 */
public static void jsonquery() {
    try {
        Settings settings = Settings.settingsBuilder().put("cluster.name", "elasticsearch1").build();
        TransportClient transportClient = TransportClient.builder().
                settings(settings).build().addTransportAddress(
                new InetSocketTransportAddress(InetAddress.getByName("172.16.2.93"), 9300));
        SearchRequestBuilder searchRequestBuilder = transportClient.prepareSearch("service2");
        SearchResponse searchResponse = searchRequestBuilder.setSource("{\n" +
                "\"query\": {\n" +
                "\"bool\": {\n" +
                "\"must\": [\n" +
                "{\n" +
                "\"prefix\": {\n" +
                "\"content\": \"oracle\"\n" +
                "}\n" +
                "}\n" +
                "],\n" +
                "\"must_not\": [ ],\n" +
                "\"should\": [ ]\n" +
                "}\n" +
                "},\n" +
                "\"from\": 0,\n" +
                "\"size\": 10,\n" +
                "\"sort\": [ ],\n" +
                "\"aggs\": { }\n" +
                "}")
                .get();
        SearchHits searchHits = searchResponse.getHits();
        System.out.println();
        System.out.println("Total Hits is " + searchHits.totalHits());
        System.out.println();
        for (int i = 0; i < searchHits.getHits().length; ++i) {
            System.out.println("content is "
                    + searchHits.getHits()[i].getSource().get("content"));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:43,代码来源:SearchES.java

示例2: testSettingsFiltering

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public void testSettingsFiltering() {
    assertAcked(client().admin().indices().prepareCreate("test-idx").setSettings(Settings.builder()
            .put("filter_test.foo", "test")
            .put("filter_test.bar1", "test")
            .put("filter_test.bar2", "test")
            .put("filter_test.notbar", "test")
            .put("filter_test.notfoo", "test")
            .build()).get());
    GetSettingsResponse response = client().admin().indices().prepareGetSettings("test-idx").get();
    Settings settings = response.getIndexToSettings().get("test-idx");

    assertThat(settings.get("index.filter_test.foo"), nullValue());
    assertThat(settings.get("index.filter_test.bar1"), nullValue());
    assertThat(settings.get("index.filter_test.bar2"), nullValue());
    assertThat(settings.get("index.filter_test.notbar"), equalTo("test"));
    assertThat(settings.get("index.filter_test.notfoo"), equalTo("test"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:SettingsFilteringIT.java

示例3: sqlToEsQuery

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public static String sqlToEsQuery(String sql) throws Exception {
        Map actions = new HashMap();
        Settings settings = Settings.builder().build();
//        Client client = new NodeClient(settings, null, null, actions);
//        Settings.builder()
//                .put(ThreadContext.PREFIX + ".key1", "val1")
//                .put(ThreadContext.PREFIX + ".key2", "val 2")
//                .build();

        ThreadPool threadPool = new ThreadPool(settings);
        Client client = new NodeClient(settings, threadPool);
        SearchDao searchDao = new org.nlpcn.es4sql.SearchDao(client);
        try {
            return searchDao.explain(sql).explain().explain();
        } catch (Exception e) {
            throw e;
        }
    }
 
开发者ID:mazhou,项目名称:es-sql,代码行数:19,代码来源:Test.java

示例4: testCustomRules

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public void testCustomRules() throws Exception {
    RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new ULocale("de_DE"));
    String DIN5007_2_tailorings =
            "& ae , a\u0308 & AE , A\u0308"+
                    "& oe , o\u0308 & OE , O\u0308"+
                    "& ue , u\u0308 & UE , u\u0308";

    RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
    String tailoredRules = tailoredCollator.getRules();

    Settings settings = Settings.builder()
            .put("index.analysis.filter.myCollator.type", "icu_collation")
            .put("index.analysis.filter.myCollator.rules", tailoredRules)
            .put("index.analysis.filter.myCollator.strength", "primary")
            .build();
    TestAnalysis analysis = createTestAnalysis(new Index("test", "_na_"), settings, new AnalysisICUPlugin());

    TokenFilterFactory filterFactory = analysis.tokenFilter.get("myCollator");
    assertCollatesToSame(filterFactory, "Töne", "Toene");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:SimpleIcuCollationTokenFilterTests.java

示例5: TransportNodesAction

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
protected TransportNodesAction(Settings settings, String actionName, ThreadPool threadPool,
                               ClusterService clusterService, TransportService transportService, ActionFilters actionFilters,
                               IndexNameExpressionResolver indexNameExpressionResolver,
                               Supplier<NodesRequest> request, Supplier<NodeRequest> nodeRequest,
                               String nodeExecutor,
                               Class<NodeResponse> nodeResponseClass) {
    super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, request);
    this.clusterService = Objects.requireNonNull(clusterService);
    this.transportService = Objects.requireNonNull(transportService);
    this.nodeResponseClass = Objects.requireNonNull(nodeResponseClass);

    this.transportNodeAction = actionName + "[n]";

    transportService.registerRequestHandler(
        transportNodeAction, nodeRequest, nodeExecutor, new NodeTransportHandler());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:TransportNodesAction.java

示例6: createTestAnalysis

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
private static TestAnalysis createTestAnalysis() throws IOException {
    InputStream keywords = IcuTokenizerFactoryTests.class.getResourceAsStream("KeywordTokenizer.rbbi");
    InputStream latin = IcuTokenizerFactoryTests.class.getResourceAsStream("Latin-dont-break-on-hyphens.rbbi");

    Path home = createTempDir();
    Path config = home.resolve("config");
    Files.createDirectory(config);
    Files.copy(keywords, config.resolve("KeywordTokenizer.rbbi"));
    Files.copy(latin, config.resolve("Latin-dont-break-on-hyphens.rbbi"));

    String json = "/org/elasticsearch/index/analysis/icu_analysis.json";

    Settings settings = Settings.builder()
        .loadFromStream(json, IcuTokenizerFactoryTests.class.getResourceAsStream(json))
        .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
        .build();
    Settings nodeSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), home).build();

    return createTestAnalysis(new Index("test", "_na_"), nodeSettings, settings, new AnalysisICUPlugin());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:IcuTokenizerFactoryTests.java

示例7: testDiscoverSingleNode

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public void testDiscoverSingleNode() throws Exception {
    List<DiscoveryNode> knownNodes = new CopyOnWriteArrayList<>();
    try (MockTransportService seedTransport = startTransport("seed_node", knownNodes, Version.CURRENT);
         MockTransportService discoverableTransport = startTransport("discoverable_node", knownNodes, Version.CURRENT)) {
        DiscoveryNode seedNode = seedTransport.getLocalDiscoNode();
        DiscoveryNode discoverableNode = discoverableTransport.getLocalDiscoNode();
        knownNodes.add(seedTransport.getLocalDiscoNode());
        knownNodes.add(discoverableTransport.getLocalDiscoNode());
        Collections.shuffle(knownNodes, random());

        try (MockTransportService service = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, threadPool, null)) {
            service.start();
            service.acceptIncomingRequests();
            try (RemoteClusterConnection connection = new RemoteClusterConnection(Settings.EMPTY, "test-cluster",
                Arrays.asList(seedNode), service, Integer.MAX_VALUE, n -> true)) {
                updateSeedNodes(connection, Arrays.asList(seedNode));
                assertTrue(service.nodeConnected(seedNode));
                assertTrue(service.nodeConnected(discoverableNode));
                assertTrue(connection.assertNoRunningConnections());
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RemoteClusterConnectionTests.java

示例8: main

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public static void main(String[] args) {
    // initialize default for es.logger.level because we will not read the logging.yml
    String loggerLevel = System.getProperty("es.logger.level", "INFO");
    // Set the appender for all potential log files to terminal so that other components that use the logger print out the
    // same terminal.
    // The reason for this is that the plugin cli cannot be configured with a file appender because when the plugin command is
    // executed there is no way of knowing where the logfiles should be placed. For example, if elasticsearch
    // is run as service then the logs should be at /var/log/elasticsearch but when started from the tar they should be at es.home/logs.
    // Therefore we print to Terminal.
    Environment env = InternalSettingsPreparer.prepareEnvironment(Settings.builder()
            .put("appender.terminal.type", "terminal")
            .put("rootLogger", "${es.logger.level}, terminal")
            .put("es.logger.level", loggerLevel)
            .build(), Terminal.DEFAULT);
    // configure but do not read the logging conf file
    LogConfigurator.configure(env.settings(), false);
    int status = new PluginManagerCliParser().execute(args).status();
    exit(status);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:PluginManagerCliParser.java

示例9: testTaskManagementOptOut

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public void testTaskManagementOptOut() throws Exception {
    setupTestNodes(Settings.EMPTY);
    connectNodes(testNodes);
    CountDownLatch checkLatch = new CountDownLatch(1);
    // Starting actions that disable task manager
    ActionFuture<NodesResponse> future = startBlockingTestNodesAction(checkLatch, new NodesRequest("Test Request", false));

    TestNode testNode = testNodes[randomIntBetween(0, testNodes.length - 1)];

    // Get the parent task
    ListTasksRequest listTasksRequest = new ListTasksRequest();
    listTasksRequest.setActions("testAction*");
    ListTasksResponse response = testNode.transportListTasksAction.execute(listTasksRequest).get();
    assertEquals(0, response.getTasks().size());

    // Release all tasks and wait for response
    checkLatch.countDown();
    NodesResponse responses = future.get();
    assertEquals(0, responses.failureCount());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:TransportTasksActionTests.java

示例10: build

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
protected MockTransportService build(Settings settings, Version version) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    MockTransportService transportService =
        new MockTransportService(
            Settings.builder()
                .put(settings)
                // trace zenfd actions but keep the default otherwise
                .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), singleton(TransportLivenessAction.NAME))
                .build(),
            new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService,
                namedWriteableRegistry, new NetworkService(settings, Collections.emptyList()), version),
            threadPool,
            TransportService.NOOP_TRANSPORT_INTERCEPTOR,
            (boundAddress) ->
                new DiscoveryNode(Node.NODE_NAME_SETTING.get(settings), boundAddress.publishAddress(),
                    Node.NODE_ATTRIBUTES.get(settings).getAsMap(), DiscoveryNode.getRolesFromSettings(settings), version),
            null);
    transportService.start();
    transportService.acceptIncomingRequests();
    return transportService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ZenFaultDetectionTests.java

示例11: testUnexpectedDiffPublishing

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public void testUnexpectedDiffPublishing() throws Exception {
    MockNode nodeA = createMockNode("nodeA", Settings.EMPTY, event -> {
        fail("Shouldn't send cluster state to myself");
    }).setAsMaster();

    MockNode nodeB = createMockNode("nodeB");

    // Initial cluster state with both states - the second node still shouldn't
    // get diff even though it's present in the previous cluster state
    DiscoveryNodes discoveryNodes = DiscoveryNodes.builder(nodeA.nodes()).add(nodeB.discoveryNode).build();
    ClusterState previousClusterState = ClusterState.builder(CLUSTER_NAME).nodes(discoveryNodes).build();
    ClusterState clusterState = ClusterState.builder(previousClusterState).incrementVersion().build();
    publishStateAndWait(nodeA.action, clusterState, previousClusterState);
    assertSameStateFromFull(nodeB.clusterState, clusterState);

    // cluster state update - add block
    previousClusterState = clusterState;
    clusterState = ClusterState.builder(clusterState).blocks(ClusterBlocks.builder()
        .addGlobalBlock(MetaData.CLUSTER_READ_ONLY_BLOCK)).incrementVersion().build();
    publishStateAndWait(nodeA.action, clusterState, previousClusterState);
    assertSameStateFromDiff(nodeB.clusterState, clusterState);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:PublishClusterStateActionTests.java

示例12: testMultipleShardsSingleNodeAllocation

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
public void testMultipleShardsSingleNodeAllocation() throws Exception {
    client().admin().indices().prepareCreate("test").setSettings(Settings.builder()
            .put("index.number_of_shards", "4").put("index.number_of_replicas", 0).put("index.routing.allocation.include.tag", "A")).execute().actionGet();
    ensureGreen();

    ClusterSearchShardsResponse response = client().admin().cluster().prepareSearchShards("test").execute().actionGet();
    assertThat(response.getGroups().length, equalTo(4));
    assertThat(response.getGroups()[0].getShardId().getIndexName(), equalTo("test"));
    assertThat(response.getNodes().length, equalTo(1));
    assertThat(response.getGroups()[0].getShards()[0].currentNodeId(), equalTo(response.getNodes()[0].getId()));

    response = client().admin().cluster().prepareSearchShards("test").setRouting("ABC").execute().actionGet();
    assertThat(response.getGroups().length, equalTo(1));

    response = client().admin().cluster().prepareSearchShards("test").setPreference("_shards:2").execute().actionGet();
    assertThat(response.getGroups().length, equalTo(1));
    assertThat(response.getGroups()[0].getShardId().getId(), equalTo(2));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ClusterSearchShardsIT.java

示例13: addColumnToTable

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
private void addColumnToTable(AddColumnAnalyzedStatement analysis, final SettableFuture<Long> result) {
    boolean updateTemplate = analysis.table().isPartitioned();
    List<ListenableFuture<Long>> results = new ArrayList<>(2);
    final Map<String, Object> mapping = analysis.analyzedTableElements().toMapping();

    if (updateTemplate) {
        results.add(updateTemplate(mapping, Settings.EMPTY, analysis.table().ident(), analysis));
    }

    String[] indexNames = getIndexNames(analysis.table(), null);
    if (indexNames.length > 0) {
        results.add(updateMapping(mapping, indexNames));
    }

    applyMultiFutureCallback(result, results);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:AlterTableOperation.java

示例14: setUp

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    Settings settings = Settings.builder()
            .put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false)
            .build();
    clusterService = createClusterService(threadPool);
    Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
            new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()),
            new NetworkService(settings, Collections.emptyList()));
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool,
        TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    ShardStateAction shardStateAction = new ShardStateAction(settings, clusterService, transportService, null, null, threadPool);
    ActionFilters actionFilters = new ActionFilters(Collections.emptySet());
    IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
    AutoCreateIndex autoCreateIndex = new AutoCreateIndex(settings, new ClusterSettings(settings,
            ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), indexNameExpressionResolver);
    UpdateHelper updateHelper = new UpdateHelper(settings, null);
    TransportShardBulkAction shardBulkAction = new TransportShardBulkAction(settings, transportService, clusterService,
            indicesService, threadPool, shardStateAction, null, updateHelper, actionFilters, indexNameExpressionResolver);
    transportBulkAction = new TransportBulkAction(settings, threadPool, transportService, clusterService,
            null, shardBulkAction, null, actionFilters, indexNameExpressionResolver, autoCreateIndex, System::currentTimeMillis);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:DynamicMappingDisabledTests.java

示例15: createIndex

import org.elasticsearch.common.settings.Settings; //导入依赖的package包/类
private int createIndex(boolean singleShard) throws Exception {
    Settings.Builder settings = Settings.builder();
    if (singleShard) {
        settings.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1);
    }
    // no replicas, as they might be ordered differently
    settings.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0);

    assertAcked(prepareCreate("test").setSettings(settings.build()).get());
    final int numDocs = randomIntBetween(10, 200);

    IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
    for (int i = 0; i < numDocs; ++i) {
        builders[i] = client().prepareIndex("test", "type", Integer.toString(i)).setSource("foo", random().nextBoolean());
    }
    indexRandom(true, builders);
    return numDocs;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:DuelScrollIT.java


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