/* 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 System.Runtime.Serialization; namespace OpenSearch.Client { /// /// Configures the source for a reindex API request /// public interface IReindexSource { /// /// The indices to target /// [DataMember(Name ="index")] Indices Index { get; set; } /// /// Search query to execute to match documents for reindexing /// [DataMember(Name ="query")] QueryContainer Query { get; set; } /// /// Reindex from a remote OpenSearch cluster /// [DataMember(Name ="remote")] IRemoteSource Remote { get; set; } /// /// The batch size of documents /// [DataMember(Name ="size")] int? Size { get; set; } /// /// Manually parallelize the reindexing process. /// This parallelization can improve efficiency and provide a convenient /// way to break the request down into smaller parts. /// /// /// Automatic slicing can be performed using /// [DataMember(Name ="slice")] ISlicedScroll Slice { get; set; } /// /// Individual fields from _source to reindex /// [DataMember(Name ="_source")] Fields Source { get; set; } } /// public class ReindexSource : IReindexSource { /// public Indices Index { get; set; } /// public QueryContainer Query { get; set; } /// public IRemoteSource Remote { get; set; } /// public int? Size { get; set; } /// public ISlicedScroll Slice { get; set; } /// public Fields Source { get; set; } } /// public class ReindexSourceDescriptor : DescriptorBase, IReindexSource { Indices IReindexSource.Index { get; set; } QueryContainer IReindexSource.Query { get; set; } IRemoteSource IReindexSource.Remote { get; set; } int? IReindexSource.Size { get; set; } ISlicedScroll IReindexSource.Slice { get; set; } Fields IReindexSource.Source { get; set; } /// public ReindexSourceDescriptor Query(Func, QueryContainer> querySelector) where T : class => Assign(querySelector, (a, v) => a.Query = v?.Invoke(new QueryContainerDescriptor())); /// public ReindexSourceDescriptor Remote(Func selector) => Assign(selector, (a, v) => a.Remote = v?.Invoke(new RemoteSourceDescriptor())); /// public ReindexSourceDescriptor Index(Indices indices) => Assign(indices, (a, v) => a.Index = v); /// public ReindexSourceDescriptor Size(int? size) => Assign(size, (a, v) => a.Size = v); /// public ReindexSourceDescriptor Slice(Func, ISlicedScroll> selector) where T : class => Assign(selector, (a, v) => a.Slice = v?.Invoke(new SlicedScrollDescriptor())); /// public ReindexSourceDescriptor Source(Func, IPromise> fields) where T : class => Assign(fields, (a, v) => a.Source = v?.Invoke(new FieldsDescriptor())?.Value); } }