Search in sources :

Example 1 with GetSettingsResponse

use of org.opensearch.action.admin.indices.settings.get.GetSettingsResponse in project OpenSearch by opensearch-project.

the class IndicesClientIT method testGetSettingsWithDefaultsFiltered.

public void testGetSettingsWithDefaultsFiltered() throws IOException {
    String indexName = "get_settings_index";
    Settings basicSettings = Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build();
    createIndex(indexName, basicSettings);
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(indexName).names("index.refresh_interval").includeDefaults(true);
    GetSettingsResponse getSettingsResponse = execute(getSettingsRequest, highLevelClient().indices()::getSettings, highLevelClient().indices()::getSettingsAsync);
    assertNull(getSettingsResponse.getSetting(indexName, "index.number_of_replicas"));
    assertNull(getSettingsResponse.getSetting(indexName, "index.number_of_shards"));
    assertEquals(0, getSettingsResponse.getIndexToSettings().get("get_settings_index").size());
    assertEquals(1, getSettingsResponse.getIndexToDefaultSettings().get("get_settings_index").size());
}
Also used : GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Example 2 with GetSettingsResponse

use of org.opensearch.action.admin.indices.settings.get.GetSettingsResponse in project OpenSearch by opensearch-project.

the class IndicesClientIT method testGetSettings.

public void testGetSettings() throws IOException {
    String indexName = "get_settings_index";
    Settings basicSettings = Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build();
    createIndex(indexName, basicSettings);
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(indexName);
    GetSettingsResponse getSettingsResponse = execute(getSettingsRequest, highLevelClient().indices()::getSettings, highLevelClient().indices()::getSettingsAsync);
    assertNull(getSettingsResponse.getSetting(indexName, "index.refresh_interval"));
    assertEquals("1", getSettingsResponse.getSetting(indexName, "index.number_of_shards"));
    updateIndexSettings(indexName, Settings.builder().put("refresh_interval", "30s"));
    GetSettingsResponse updatedResponse = execute(getSettingsRequest, highLevelClient().indices()::getSettings, highLevelClient().indices()::getSettingsAsync);
    assertEquals("30s", updatedResponse.getSetting(indexName, "index.refresh_interval"));
}
Also used : GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Example 3 with GetSettingsResponse

use of org.opensearch.action.admin.indices.settings.get.GetSettingsResponse in project OpenSearch by opensearch-project.

the class IndicesClientIT method testGetSettingsFiltered.

public void testGetSettingsFiltered() throws IOException {
    String indexName = "get_settings_index";
    Settings basicSettings = Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build();
    createIndex(indexName, basicSettings);
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(indexName).names("index.number_of_shards");
    GetSettingsResponse getSettingsResponse = execute(getSettingsRequest, highLevelClient().indices()::getSettings, highLevelClient().indices()::getSettingsAsync);
    assertNull(getSettingsResponse.getSetting(indexName, "index.number_of_replicas"));
    assertEquals("1", getSettingsResponse.getSetting(indexName, "index.number_of_shards"));
    assertEquals(1, getSettingsResponse.getIndexToSettings().get("get_settings_index").size());
}
Also used : GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Example 4 with GetSettingsResponse

use of org.opensearch.action.admin.indices.settings.get.GetSettingsResponse in project OpenSearch by opensearch-project.

the class IndicesClientIT method testGetSettingsWithDefaults.

public void testGetSettingsWithDefaults() throws IOException {
    String indexName = "get_settings_index";
    Settings basicSettings = Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build();
    createIndex(indexName, basicSettings);
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(indexName).includeDefaults(true);
    GetSettingsResponse getSettingsResponse = execute(getSettingsRequest, highLevelClient().indices()::getSettings, highLevelClient().indices()::getSettingsAsync);
    assertNotNull(getSettingsResponse.getSetting(indexName, "index.refresh_interval"));
    assertEquals(IndexSettings.DEFAULT_REFRESH_INTERVAL, getSettingsResponse.getIndexToDefaultSettings().get("get_settings_index").getAsTime("index.refresh_interval", null));
    assertEquals("1", getSettingsResponse.getSetting(indexName, "index.number_of_shards"));
}
Also used : GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Example 5 with GetSettingsResponse

use of org.opensearch.action.admin.indices.settings.get.GetSettingsResponse in project OpenSearch by opensearch-project.

the class IndicesClientIT method testGetSettingsFromMultipleIndices.

public void testGetSettingsFromMultipleIndices() throws IOException {
    String indexName1 = "get_multiple_settings_one";
    createIndex(indexName1, Settings.builder().put("number_of_shards", 2).build());
    String indexName2 = "get_multiple_settings_two";
    createIndex(indexName2, Settings.builder().put("number_of_shards", 3).build());
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices("get_multiple_settings*");
    GetSettingsResponse getSettingsResponse = execute(getSettingsRequest, highLevelClient().indices()::getSettings, highLevelClient().indices()::getSettingsAsync);
    assertEquals("2", getSettingsResponse.getSetting(indexName1, "index.number_of_shards"));
    assertEquals("3", getSettingsResponse.getSetting(indexName2, "index.number_of_shards"));
}
Also used : GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Matchers.containsString(org.hamcrest.Matchers.containsString)

Aggregations

GetSettingsResponse (org.opensearch.action.admin.indices.settings.get.GetSettingsResponse)31 Settings (org.opensearch.common.settings.Settings)14 Matchers.containsString (org.hamcrest.Matchers.containsString)10 GetSettingsRequest (org.opensearch.action.admin.indices.settings.get.GetSettingsRequest)8 IndexSettings (org.opensearch.index.IndexSettings)7 Sort (org.apache.lucene.search.Sort)4 SortField (org.apache.lucene.search.SortField)4 SortedSetSortField (org.apache.lucene.search.SortedSetSortField)4 IndicesStatsResponse (org.opensearch.action.admin.indices.stats.IndicesStatsResponse)4 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)4 Version (org.opensearch.Version)3 ActionListener (org.opensearch.action.ActionListener)3 ClusterStateRequest (org.opensearch.action.admin.cluster.state.ClusterStateRequest)3 ClusterStateResponse (org.opensearch.action.admin.cluster.state.ClusterStateResponse)3 CommonStats (org.opensearch.action.admin.indices.stats.CommonStats)3 Client (org.opensearch.client.Client)3 ClusterState (org.opensearch.cluster.ClusterState)3 TermsQueryBuilder (org.opensearch.index.query.TermsQueryBuilder)3 SeqNoStats (org.opensearch.index.seqno.SeqNoStats)3 IOException (java.io.IOException)2