Search in sources :

Example 1 with GetSettingsRequest

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

the class IndicesRequestConverters method getSettings.

static Request getSettings(GetSettingsRequest getSettingsRequest) {
    String[] indices = getSettingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.indices();
    String[] names = getSettingsRequest.names() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.names();
    String endpoint = RequestConverters.endpoint(indices, "_settings", names);
    Request request = new Request(HttpGet.METHOD_NAME, endpoint);
    RequestConverters.Params params = new RequestConverters.Params();
    params.withIndicesOptions(getSettingsRequest.indicesOptions());
    params.withLocal(getSettingsRequest.local());
    params.withIncludeDefaults(getSettingsRequest.includeDefaults());
    params.withMasterTimeout(getSettingsRequest.masterNodeTimeout());
    request.addParameters(params.asMap());
    return request;
}
Also used : UpdateSettingsRequest(org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest) CreateIndexRequest(org.opensearch.client.indices.CreateIndexRequest) SimulateIndexTemplateRequest(org.opensearch.client.indices.SimulateIndexTemplateRequest) FlushRequest(org.opensearch.action.admin.indices.flush.FlushRequest) RefreshRequest(org.opensearch.action.admin.indices.refresh.RefreshRequest) GetIndexRequest(org.opensearch.client.indices.GetIndexRequest) DeleteAliasRequest(org.opensearch.client.indices.DeleteAliasRequest) OpenIndexRequest(org.opensearch.action.admin.indices.open.OpenIndexRequest) GetFieldMappingsRequest(org.opensearch.client.indices.GetFieldMappingsRequest) ForceMergeRequest(org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest) GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) GetDataStreamRequest(org.opensearch.client.indices.GetDataStreamRequest) DeleteIndexRequest(org.opensearch.action.admin.indices.delete.DeleteIndexRequest) ComposableIndexTemplateExistRequest(org.opensearch.client.indices.ComposableIndexTemplateExistRequest) AnalyzeRequest(org.opensearch.client.indices.AnalyzeRequest) ResizeRequest(org.opensearch.client.indices.ResizeRequest) GetComposableIndexTemplateRequest(org.opensearch.client.indices.GetComposableIndexTemplateRequest) DataStreamsStatsRequest(org.opensearch.client.indices.DataStreamsStatsRequest) DeleteIndexTemplateRequest(org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) CloseIndexRequest(org.opensearch.client.indices.CloseIndexRequest) GetIndexTemplatesRequest(org.opensearch.client.indices.GetIndexTemplatesRequest) GetMappingsRequest(org.opensearch.client.indices.GetMappingsRequest) GetAliasesRequest(org.opensearch.action.admin.indices.alias.get.GetAliasesRequest) PutComposableIndexTemplateRequest(org.opensearch.client.indices.PutComposableIndexTemplateRequest) CreateDataStreamRequest(org.opensearch.client.indices.CreateDataStreamRequest) IndicesAliasesRequest(org.opensearch.action.admin.indices.alias.IndicesAliasesRequest) PutMappingRequest(org.opensearch.client.indices.PutMappingRequest) DeleteComposableIndexTemplateRequest(org.opensearch.client.indices.DeleteComposableIndexTemplateRequest) PutIndexTemplateRequest(org.opensearch.client.indices.PutIndexTemplateRequest) ValidateQueryRequest(org.opensearch.action.admin.indices.validate.query.ValidateQueryRequest) DeleteDataStreamRequest(org.opensearch.client.indices.DeleteDataStreamRequest) ClearIndicesCacheRequest(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest) IndexTemplatesExistRequest(org.opensearch.client.indices.IndexTemplatesExistRequest) RolloverRequest(org.opensearch.client.indices.rollover.RolloverRequest)

Example 2 with GetSettingsRequest

use of org.opensearch.action.admin.indices.settings.get.GetSettingsRequest 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 3 with GetSettingsRequest

use of org.opensearch.action.admin.indices.settings.get.GetSettingsRequest 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 4 with GetSettingsRequest

use of org.opensearch.action.admin.indices.settings.get.GetSettingsRequest 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 5 with GetSettingsRequest

use of org.opensearch.action.admin.indices.settings.get.GetSettingsRequest 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)

Aggregations

GetSettingsRequest (org.opensearch.action.admin.indices.settings.get.GetSettingsRequest)13 GetSettingsResponse (org.opensearch.action.admin.indices.settings.get.GetSettingsResponse)7 Matchers.containsString (org.hamcrest.Matchers.containsString)6 Settings (org.opensearch.common.settings.Settings)6 IndexSettings (org.opensearch.index.IndexSettings)6 CreateIndexRequest (org.opensearch.client.indices.CreateIndexRequest)4 IOException (java.io.IOException)3 OpenSearchException (org.opensearch.OpenSearchException)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 ActionListener (org.opensearch.action.ActionListener)2 LatchedActionListener (org.opensearch.action.LatchedActionListener)2 IndicesAliasesRequest (org.opensearch.action.admin.indices.alias.IndicesAliasesRequest)2 GetAliasesRequest (org.opensearch.action.admin.indices.alias.get.GetAliasesRequest)2 ClearIndicesCacheRequest (org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest)2 DeleteIndexRequest (org.opensearch.action.admin.indices.delete.DeleteIndexRequest)2 FlushRequest (org.opensearch.action.admin.indices.flush.FlushRequest)2 ForceMergeRequest (org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest)2 OpenIndexRequest (org.opensearch.action.admin.indices.open.OpenIndexRequest)2 RefreshRequest (org.opensearch.action.admin.indices.refresh.RefreshRequest)2 UpdateSettingsRequest (org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest)2