/* SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ /* * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. * * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ using System; using System.Collections.Generic; using OpenSearch.Net.Utf8Json; namespace OpenSearch.Client.Specification.IndicesApi { /// /// The settings for an index /// [InterfaceDataContract] [JsonFormatter(typeof(IndexSettingsFormatter))] public interface IIndexSettings : IDynamicIndexSettings { /// /// The store module allows you to control how index data is stored and accessed on disk. /// EXPERT MODE toggle /// FileSystemStorageImplementation? FileSystemStorageImplementation { get; set; } /// /// The number of routing shards. Used in conjunction with the Split Index API. If specified, must be /// greater than or equal to /// int? NumberOfRoutingShards { get; set; } /// /// The number of primary shards that an index should have. Defaults to 1. /// This setting can only be set at index creation time. It cannot be changed on a closed index. /// int? NumberOfShards { get; set; } /// Settings associated with queries. IQueriesSettings Queries { get; set; } /// /// By defaulting, routing resolves to a single shard. Use this settings to have it resolve to a set of shards instead. /// This mitigates creating hotspots and very large shards if you have a few routing keys generating the significant data. /// int? RoutingPartitionSize { get; set; } /// /// Indicates whether the index should be hidden by default. /// Hidden indices are not returned by default when using a wildcard expression. /// bool? Hidden { get; set; } /// /// Settings associated with index sorting. /// /// ISortingSettings Sorting { get; set; } /// Soft delete settings for the index ISoftDeleteSettings SoftDeletes { get; set; } } /// public class IndexSettings : DynamicIndexSettings, IIndexSettings { public IndexSettings() { } public IndexSettings(IDictionary container) : base(container) { } /// public FileSystemStorageImplementation? FileSystemStorageImplementation { get; set; } /// public int? NumberOfRoutingShards { get; set; } /// public int? NumberOfShards { get; set; } /// public IQueriesSettings Queries { get; set; } /// public int? RoutingPartitionSize { get; set; } /// public bool? Hidden { get; set; } /// public ISortingSettings Sorting { get; set; } /// public ISoftDeleteSettings SoftDeletes { get; set; } } /// public class IndexSettingsDescriptor : DynamicIndexSettingsDescriptorBase { public IndexSettingsDescriptor() : base(new IndexSettings()) { } /// public IndexSettingsDescriptor NumberOfShards(int? numberOfShards) => Assign(numberOfShards, (a, v) => a.NumberOfShards = v); /// public IndexSettingsDescriptor NumberOfRoutingShards(int? numberOfRoutingShards) => Assign(numberOfRoutingShards, (a, v) => a.NumberOfRoutingShards = v); /// public IndexSettingsDescriptor RoutingPartitionSize(int? routingPartitionSize) => Assign(routingPartitionSize, (a, v) => a.RoutingPartitionSize = v); /// public IndexSettingsDescriptor Hidden(bool? hidden = true) => Assign(hidden, (a, v) => a.Hidden = v); /// public IndexSettingsDescriptor FileSystemStorageImplementation(FileSystemStorageImplementation? fs) => Assign(fs, (a, v) => a.FileSystemStorageImplementation = v); /// public IndexSettingsDescriptor Queries(Func selector) => Assign(selector, (a, v) => a.Queries = v?.Invoke(new QueriesSettingsDescriptor())); /// public IndexSettingsDescriptor Sorting(Func, ISortingSettings> selector) where T : class => Assign(selector, (a, v) => a.Sorting = v?.Invoke(new SortingSettingsDescriptor())); /// public IndexSettingsDescriptor SoftDeletes(Func selector) => Assign(selector, (a, v) => a.SoftDeletes = v?.Invoke(new SoftDeleteSettingsDescriptor())); } }