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


Java GetSettingsRequest类代码示例

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


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

示例1: should_create_index_with_settings

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Test
public void should_create_index_with_settings() throws ExecutionException, InterruptedException {
    String settings = TestFilesUtils.readFromClasspath("com/github/obourgain/elasticsearch/http/handler/admin/indices/create_index_with_settings.json");

    CreateIndexResponse response = httpClient.admin().indices()
            .createIndex(Requests.createIndexRequest(THE_INDEX)
            .settings(settings))
            .get();
    Assertions.assertThat(response.isAcknowledged()).isTrue();

    GetSettingsResponse getSettingsResponse = transportClient.admin().indices().getSettings(new GetSettingsRequest().indices(THE_INDEX)).actionGet();
    ImmutableOpenMap<String, Settings> indexToSettings = getSettingsResponse.getIndexToSettings();
    Assertions.assertThat(indexToSettings.iterator().hasNext()).isTrue();
    Assertions.assertThat(indexToSettings.iterator().next().key).isEqualTo(THE_INDEX);

    Settings expectedSettings = ImmutableSettings.builder().loadFromSource(settings).build();
    Settings actualSettings = indexToSettings.get(THE_INDEX);
    assertSettingsEquals(expectedSettings, actualSettings);
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:20,代码来源:CreateIndexActionHandlerTest.java

示例2: should_update_settings

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Test
public void should_update_settings() throws Exception {
    String index = "to_update_indices";
    createIndex(index);
    GetSettingsResponse initial = transportClient.admin().indices().getSettings(new GetSettingsRequest().indices(index)).actionGet();
    Assertions.assertThat(initial.getIndexToSettings().get(index).get("index.number_of_replicas")).isNotEqualTo("5");

    UpdateSettingsResponse response = httpClient.admin().indices().updateSettings(
            new UpdateSettingsRequest(index)
                    .settings(singletonMap("index.number_of_replicas", 5))
    ).get();

    Assertions.assertThat(response.isAcknowledged()).isTrue();

    GetSettingsResponse expected = transportClient.admin().indices().getSettings(new GetSettingsRequest().indices(index)).actionGet();
    Assertions.assertThat(expected.getIndexToSettings().get(index).get("index.number_of_replicas")).isEqualTo("5");
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:18,代码来源:UpdateSettingsActionHandlerTest.java

示例3: prepareRequest

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    final String[] names = request.paramAsStringArrayOrEmptyIfAll("name");
    final boolean renderDefaults = request.paramAsBoolean("include_defaults", false);
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest()
            .indices(Strings.splitStringByCommaToArray(request.param("index")))
            .indicesOptions(IndicesOptions.fromRequest(request, IndicesOptions.strictExpandOpen()))
            .humanReadable(request.hasParam("human"))
            .names(names);
    getSettingsRequest.local(request.paramAsBoolean("local", getSettingsRequest.local()));

    return channel -> client.admin().indices().getSettings(getSettingsRequest, new RestBuilderListener<GetSettingsResponse>(channel) {

        @Override
        public RestResponse buildResponse(GetSettingsResponse getSettingsResponse, XContentBuilder builder) throws Exception {
            builder.startObject();
            for (ObjectObjectCursor<String, Settings> cursor : getSettingsResponse.getIndexToSettings()) {
                // no settings, jump over it to shorten the response data
                if (cursor.value.isEmpty()) {
                    continue;
                }
                builder.startObject(cursor.key);
                builder.startObject("settings");
                cursor.value.toXContent(builder, request);
                builder.endObject();
                if (renderDefaults) {
                    builder.startObject("defaults");
                    settingsFilter.filter(indexScopedSettings.diff(cursor.value, settings)).toXContent(builder, request);
                    builder.endObject();
                }
                builder.endObject();
            }
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:RestGetSettingsAction.java

示例4: testGetSettings

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
public void testGetSettings() {
    interceptTransportActions(GetSettingsAction.NAME);

    GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(randomIndicesOrAliases());
    internalCluster().coordOnlyNodeClient().admin().indices().getSettings(getSettingsRequest).actionGet();

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

示例5: handleRequest

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final String[] names = request.paramAsStringArrayOrEmptyIfAll("name");
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest()
            .indices(Strings.splitStringByCommaToArray(request.param("index")))
            .indicesOptions(IndicesOptions.fromRequest(request, IndicesOptions.strictExpandOpen()))
            .humanReadable(request.hasParam("human"))
            .names(names);
    getSettingsRequest.local(request.paramAsBoolean("local", getSettingsRequest.local()));

    client.admin().indices().getSettings(getSettingsRequest, new RestBuilderListener<GetSettingsResponse>(channel) {

        @Override
        public RestResponse buildResponse(GetSettingsResponse getSettingsResponse, XContentBuilder builder) throws Exception {
            builder.startObject();
            for (ObjectObjectCursor<String, Settings> cursor : getSettingsResponse.getIndexToSettings()) {
                // no settings, jump over it to shorten the response data
                if (cursor.value.getAsMap().isEmpty()) {
                    continue;
                }
                builder.startObject(cursor.key, XContentBuilder.FieldCaseConversion.NONE);
                builder.startObject(Fields.SETTINGS);
                cursor.value.toXContent(builder, request);
                builder.endObject();
                builder.endObject();
            }
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:32,代码来源:RestGetSettingsAction.java

示例6: testIndexCreationOptions

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Test
public void testIndexCreationOptions() throws InterruptedException, BackendException {
    final int shards = 77;

    ElasticsearchRunner esr = new ElasticsearchRunner(".", "indexCreationOptions.yml");
    esr.start();
    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.create.ext.number_of_shards", String.valueOf(shards));
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.cluster.name", "indexCreationOptions");
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);



    ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
    settingsBuilder.put("discovery.zen.ping.multicast.enabled", "false");
    settingsBuilder.put("discovery.zen.ping.unicast.hosts", "localhost,127.0.0.1:9300");
    settingsBuilder.put("cluster.name", "indexCreationOptions");
    NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settingsBuilder.build());
    nodeBuilder.client(true).data(false).local(false);
    Node n = nodeBuilder.build().start();

    GetSettingsResponse response = n.client().admin().indices().getSettings(new GetSettingsRequest().indices("titan")).actionGet();
    assertEquals(String.valueOf(shards), response.getSetting("titan", "index.number_of_shards"));

    idx.close();
    n.stop();
    esr.stop();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:35,代码来源:ElasticSearchConfigTest.java

示例7: prepareSearchScrollRequest

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
public SearchResponse prepareSearchScrollRequest() {
  // find out how many indices and shards are affected by this query to not get huge result sets when there are very many indices affected by the name, e.g. when wildcards are used
  // otherwise we regularly run into OOMs when a query goes against a large number of indices
  // I did not find a better way to find out the number of shards than to query a list of indices and for each index query the number of shards via the settings
  GetSettingsResponse getSettingsResponse = client.admin().indices().getSettings(new GetSettingsRequest().indices(dataPointer.getIndexName())).actionGet();
  int numShards = 0, numIndices = 0;
  for(ObjectCursor<Settings> settings : getSettingsResponse.getIndexToSettings().values()) {
    numShards += settings.value.getAsInt("index.number_of_shards", 0);
    numIndices++;
  }

  int sizePerShard = (int)Math.ceil((double)SCROLL_SHARD_LIMIT/numShards);
  logger.info("Found " + numIndices + " indices and " + numShards + " shards matching the index-pattern, thus setting the sizePerShard to " + sizePerShard);

  SearchRequestBuilder searchRequestBuilder = client.prepareSearch(dataPointer.getIndexName())
      .setTypes(dataPointer.getTypeName())
      .setSearchType(SearchType.SCAN)
      .addFields("_ttl", "_source")
      .setScroll(new TimeValue(SCROLL_TIME_LIMIT))
      .setSize(sizePerShard);

  if (!Strings.isNullOrEmpty(query.getQuery())) {
    searchRequestBuilder.setQuery(query.getQuery());
  }
  if (!Strings.isNullOrEmpty(query.getSortField())) {
    searchRequestBuilder.addSort(new FieldSortBuilder(query.getSortField()).order(query.getSortOrder()));
  }

  bound.map(resolvedBound -> boundedFilterFactory.createBoundedFilter(segmentationField.get(), resolvedBound))
      .ifPresent(searchRequestBuilder::setQuery);

  return searchRequestBuilder.execute().actionGet();
}
 
开发者ID:allegro,项目名称:elasticsearch-reindex-tool,代码行数:34,代码来源:QueryComponent.java

示例8: testElasticsearchReplicaHandlingInScrolls

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Test
public void testElasticsearchReplicaHandlingInScrolls() {
  // given
  indexWithSampleData(200);
  ElasticDataPointer sourceDataPointer = embeddedElasticsearchCluster.createDataPointer(SOURCE_INDEX);
  Client sourceClient = ElasticSearchClientFactory.createClient(sourceDataPointer);

  GetSettingsResponse indexSettings = sourceClient.admin().indices().getSettings(new GetSettingsRequest().indices(SOURCE_INDEX)).actionGet();
  assertEquals("We should have an index with 5 shards now",
          "5", indexSettings.getIndexToSettings().get(SOURCE_INDEX).get("index.number_of_shards"));
  assertEquals("We should have an index with one replica now",
          "1", indexSettings.getIndexToSettings().get(SOURCE_INDEX).get("index.number_of_replicas"));

  // when
  SearchRequestBuilder searchRequestBuilder = sourceClient.prepareSearch(sourceDataPointer.getIndexName())
          .setTypes(DATA_TYPE)
          .setSearchType(SearchType.SCAN)
          .addFields("_ttl", "_source")
          .setScroll(new TimeValue(QueryComponent.SCROLL_TIME_LIMIT))
          .setSize(10);
  assertNotNull(searchRequestBuilder);

  // then
  SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
  assertEquals("Overall there should be 200 hits",
          200L, searchResponse.getHits().getTotalHits());
  assertEquals("Initially zero documents are loaded",
          0L, searchResponse.getHits().getHits().length);

  // when
  searchResponse = sourceClient.prepareSearchScroll(searchResponse.getScrollId())
          .setScroll(new TimeValue(QueryComponent.SCROLL_TIMEOUT))
          .get();

  // then
  assertEquals(200L, searchResponse.getHits().getTotalHits());
  assertEquals(50L, searchResponse.getHits().getHits().length);
}
 
开发者ID:allegro,项目名称:elasticsearch-reindex-tool,代码行数:39,代码来源:QueryComponentTest.java

示例9: testIndexCreationOptions

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Test
public void testIndexCreationOptions() throws InterruptedException, BackendException {
    final int shards = 77;

    ElasticsearchRunner esr = new ElasticsearchRunner();
    esr.start();
    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.create.ext.number_of_shards", String.valueOf(shards));
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE, INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();


    ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
    settingsBuilder.put("discovery.zen.ping.multicast.enabled", "false");
    settingsBuilder.put("discovery.zen.ping.unicast.hosts", "localhost,127.0.0.1:9300");
    NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settingsBuilder.build());
    nodeBuilder.client(true).data(false).local(false);
    Node n = nodeBuilder.build().start();
    GetSettingsRequest request = new GetSettingsRequestBuilder((NodeClient)n.client(), "titan").request();
    GetSettingsResponse response = n.client().admin().indices().getSettings(request).actionGet();
    assertEquals(String.valueOf(shards), response.getSetting("titan", "index.number_of_shards"));

    n.stop();
    esr.stop();
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:32,代码来源:ElasticSearchConfigTest.java

示例10: execute

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
public void execute(GetSettingsRequest request, final ActionListener<GetSettingsResponse> listener) {
    logger.debug("get settings request {}", request);
    try {
        // lots of url patterns are accepted, but this one is the most practical for a generic impl
        String indices = HttpRequestUtils.indicesOrAll(request);
        RequestUriBuilder uriBuilder = new RequestUriBuilder(indices);

        String names = Strings.arrayToCommaDelimitedString(request.names());
        if (!names.isEmpty()) {
            names = "/" + names;
        }
        uriBuilder.addEndpoint("_settings" + names);

        uriBuilder.addQueryParameter("master_timeout", request.masterNodeTimeout().toString())
                .addIndicesOptions(request);

        indicesAdminClient.getHttpClient().submit(HttpClientRequest.createGet(uriBuilder.toString()))
                .flatMap(ErrorHandler.AS_FUNC)
                .flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<GetSettingsResponse>>() {
                    @Override
                    public Observable<GetSettingsResponse> call(HttpClientResponse<ByteBuf> response) {
                        return response.getContent().flatMap(new Func1<ByteBuf, Observable<GetSettingsResponse>>() {
                            @Override
                            public Observable<GetSettingsResponse> call(ByteBuf byteBuf) {
                                return GetSettingsResponse.parse(byteBuf);
                            }
                        });
                    }
                })
                .single()
                .subscribe(new ListenerCompleterObserver<>(listener));

    } catch (Exception e) {
        listener.onFailure(e);
    }
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:37,代码来源:GetSettingsActionHandler.java

示例11: should_get_settings

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
@Test
public void should_get_settings() throws Exception {
    GetSettingsResponse response = httpClient.admin().indices().getSettings(new GetSettingsRequest().indices(THE_INDEX)).get();

    Assertions.assertThat(response.getIndexToSettings()).hasSize(1);

    org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse transportResponse = transportClient.admin().indices().getSettings(new GetSettingsRequest().indices(THE_INDEX)).actionGet();
    Settings expected = transportResponse.getIndexToSettings().get(THE_INDEX);

    Assertions.assertThat(response.getIndexToSettings().get(THE_INDEX)).isEqualTo(expected);
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:12,代码来源:GetSettingsActionHandlerTest.java

示例12: getRefreshInterval

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
public ActionFuture<String> getRefreshInterval(final String index) {
    AdapterActionFuture<String, GetSettingsResponse> future = new AdapterActionFuture<String, GetSettingsResponse>() {
        @Override
        protected String convert(GetSettingsResponse listenerResponse) {
            return listenerResponse.getSetting(index, "index.refresh_interval");
        }
    };
    client.admin().indices().getSettings(new GetSettingsRequest().indices(index), future);
    return future;
}
 
开发者ID:obourgain,项目名称:elasticsearch-batch,代码行数:11,代码来源:ElasticsearchBatchOperationsAsync.java

示例13: getReplicas

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
public ActionFuture<Integer> getReplicas(final String index) {
    AdapterActionFuture<Integer, GetSettingsResponse> future = new AdapterActionFuture<Integer, GetSettingsResponse>() {
        @Override
        protected Integer convert(GetSettingsResponse listenerResponse) {
            return Integer.valueOf(listenerResponse.getSetting(index, "index.refresh_interval"));
        }
    };
    client.admin().indices().getSettings(new GetSettingsRequest().indices(index), future);
    return future;
}
 
开发者ID:obourgain,项目名称:elasticsearch-batch,代码行数:11,代码来源:ElasticsearchBatchOperationsAsync.java

示例14: getSettings

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

示例15: showIndexSettings

import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; //导入依赖的package包/类
private static void showIndexSettings(IndicesAdminClient indicesAdminClient, String indexName) {
        GetSettingsResponse settingInfo = indicesAdminClient.getSettings(new GetSettingsRequest().indices(indexName)).actionGet();
//        log.info("显示 index setting:{}", settingInfo.getIndexToSettings().get(indexName).getAsMap());
    }
 
开发者ID:ggj2010,项目名称:javabase,代码行数:5,代码来源:CrudDemo.java


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