/// <inheritdoc cref="IRestoreRequest.Indices" />
 public CloneSnapshotDescriptor Index(IndexName index) => Indices(index);
        private static Func <MultiGetOperationDescriptor <T>, string, IMultiGetOperation> Lookup <T>(IndexName index)
            where T : class
        {
            if (index == null)
            {
                return(null);
            }

            return((d, id) => d.Index(index));
        }
 public string IndexName(IndexName index) => IndexNameResolver.Resolve(index);
Example #4
0
        /// <summary>
        /// Shortcut into the Bulk call that indexes the specified objects
        /// <para> </para>
        /// https://opensearch.org/docs/latest/opensearch/rest-api/document-apis/bulk/
        /// </summary>
        /// <param name="client"></param>
        /// <typeparam name="T">The type used to infer the default index and typename</typeparam>
        /// <param name="objects">List of objects to index, Id will be inferred (Id property or IdProperty attribute on type)</param>
        /// <param name="index">Override the inferred indexname for T</param>
        /// <param name="type">Override the inferred typename for T</param>
        public static Task <BulkResponse> IndexManyAsync <T>(this IOpenSearchClient client, IEnumerable <T> objects, IndexName index = null,
                                                             CancellationToken cancellationToken = default
                                                             )
            where T : class
        {
            var bulkRequest = CreateIndexBulkRequest(objects, index);

            return(client.BulkAsync(bulkRequest, cancellationToken));
        }
Example #5
0
        private static BulkRequest CreateIndexBulkRequest <T>(IEnumerable <T> objects, IndexName index) where T : class
        {
            @objects.ThrowIfEmpty(nameof(objects));
            var bulkRequest = new BulkRequest(index);
            var indexOps    = @objects
                              .Select(o => new BulkIndexOperation <T>(o))
                              .Cast <IBulkOperation>()
                              .ToList();

            bulkRequest.Operations = new BulkOperationsCollection <IBulkOperation>(indexOps);
            return(bulkRequest);
        }
 /// <summary>
 /// Multi GET API allows to get multiple documents based on an index, type (optional) and id (and possibly routing).
 /// The response includes a docs array with all the fetched documents, each element similar in structure to a document
 /// provided by the get API.
 /// <para> </para>
 /// https://opensearch.org/docs/latest/opensearch/rest-api/document-apis/multi-get/
 /// </summary>
 /// <typeparam name="T">The type used to infer the default index and typename</typeparam>
 /// <param name="client"></param>
 /// <param name="ids">IEnumerable of ids as ints for the documents to fetch</param>
 /// <param name="index">Optionally override the default inferred index name for T</param>
 /// <param name="type">Optionally overiide the default inferred typename for T</param>
 public static IEnumerable <IMultiGetHit <T> > GetMany <T>(this IOpenSearchClient client, IEnumerable <long> ids, IndexName index = null)
     where T : class => client.GetMany <T>(ids.Select(i => i.ToString(CultureInfo.InvariantCulture)), index);
Example #7
0
        /// <summary>
        /// Shortcut into the Bulk call that indexes the specified objects
        /// <para> </para>
        /// https://opensearch.org/docs/latest/opensearch/rest-api/document-apis/bulk/
        /// </summary>
        /// <param name="client"></param>
        /// <typeparam name="T">The type used to infer the default index and typename</typeparam>
        /// <param name="objects">List of objects to index, Id will be inferred (Id property or IdProperty attribute on type)</param>
        /// <param name="index">Override the inferred indexname for T</param>
        /// <param name="type">Override the inferred typename for T</param>
        public static BulkResponse IndexMany <T>(this IOpenSearchClient client, IEnumerable <T> @objects, IndexName index = null)
            where T : class
        {
            var bulkRequest = CreateIndexBulkRequest(objects, index);

            return(client.Bulk(bulkRequest));
        }
        /// <summary>
        /// Multi GET API allows to get multiple documents based on an index, type (optional) and id (and possibly routing).
        /// The response includes a docs array with all the fetched documents, each element similar in structure to a document
        /// provided by the get API.
        /// <para> </para>
        /// https://opensearch.org/docs/latest/opensearch/rest-api/document-apis/multi-get/
        /// </summary>
        /// <typeparam name="T">The type used to infer the default index and typename</typeparam>
        /// <param name="client"></param>
        /// <param name="ids">IEnumerable of ids as string for the documents to fetch</param>
        /// <param name="index">Optionally override the default inferred index name for T</param>
        /// <param name="type">Optionally overiide the default inferred typename for T</param>
        public static IEnumerable <IMultiGetHit <T> > GetMany <T>(this IOpenSearchClient client, IEnumerable <string> ids, IndexName index = null)
            where T : class
        {
            var result = client.MultiGet(s => s
                                         .Index(index)
                                         .RequestConfiguration(r => r.ThrowExceptions())
                                         .GetMany <T>(ids, Lookup <T>(index))
                                         );

            return(result.GetMany <T>(ids));
        }
 /// <summary>
 /// Multi GET API allows to get multiple documents based on an index, type (optional) and id (and possibly routing).
 /// The response includes a docs array with all the fetched documents, each element similar in structure to a document
 /// provided by the get API.
 /// <para> </para>
 /// https://opensearch.org/docs/latest/opensearch/rest-api/document-apis/multi-get/
 /// </summary>
 /// <typeparam name="T">The type used to infer the default index and typename</typeparam>
 /// <param name="client"></param>
 /// <param name="ids">IEnumerable of ids as ints for the documents to fetch</param>
 /// <param name="index">Optionally override the default inferred index name for T</param>
 /// <param name="type">Optionally overiide the default inferred typename for T</param>
 public static Task <IEnumerable <IMultiGetHit <T> > > GetManyAsync <T>(
     this IOpenSearchClient client, IEnumerable <long> ids, IndexName index = null, CancellationToken cancellationToken = default
     )
     where T : class => client.GetManyAsync <T>(ids.Select(i => i.ToString(CultureInfo.InvariantCulture)), index, cancellationToken);
		public MoveClusterRerouteCommandDescriptor Index(IndexName index) => Assign(index, (a, v) => a.Index = v);
Example #11
0
 /// <summary>
 /// Manually set the index, default to the default index or the fixed index set on the bulk operation
 /// </summary>
 public TDescriptor Index(IndexName index) => Assign(index, (a, v) => a.Index = v);
 /// <summary>
 /// The name of the index to provide an explanation for
 /// </summary>
 public ClusterAllocationExplainDescriptor Index(IndexName index) => Assign(index, (a, v) => a.Index = v);