/// <summary> /// Shortcut into the Bulk call that deletes 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 delete</param> /// <param name="index">Override the inferred indexname for T</param> /// <param name="type">Override the inferred typename for T</param> public static BulkResponse DeleteMany <T>(this IOpenSearchClient client, IEnumerable <T> @objects, IndexName index = null) where T : class { var bulkRequest = CreateDeleteBulkRequest(objects, index); return(client.Bulk(bulkRequest)); }
public ScrollAllObservable(IOpenSearchClient client, IScrollAllRequest scrollAllRequest, CancellationToken cancellationToken = default) { _scrollAllRequest = scrollAllRequest; _searchRequest = scrollAllRequest?.Search ?? new SearchRequest <T>(); switch (_scrollAllRequest) { case IHelperCallable helperCallable when helperCallable.ParentMetaData is object: _searchRequest.RequestParameters.SetRequestMetaData(helperCallable.ParentMetaData); break; default: _searchRequest.RequestParameters.SetRequestMetaData(RequestMetaDataFactory.ScrollHelperRequestMetaData()); break; } if (_searchRequest.Sort == null) { _searchRequest.Sort = FieldSort.ByDocumentOrder; } _searchRequest.RequestParameters.Scroll = _scrollAllRequest.ScrollTime.ToTimeSpan(); _client = client; _compositeCancelTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); _compositeCancelToken = _compositeCancelTokenSource.Token; _backPressure = _scrollAllRequest.BackPressure; }
/// <summary> /// Shortcut into the Bulk call that deletes 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 delete</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> DeleteManyAsync <T>(this IOpenSearchClient client, IEnumerable <T> objects, IndexName index = null, CancellationToken cancellationToken = default ) where T : class { var bulkRequest = CreateDeleteBulkRequest(objects, index); return(client.BulkAsync(bulkRequest, cancellationToken)); }
public SnapshotObservable(IOpenSearchClient opensearchClient, ISnapshotRequest snapshotRequest, TimeSpan interval) : this(opensearchClient, snapshotRequest) { interval.ThrowIfNull(nameof(interval)); if (interval.Ticks < 0) { throw new ArgumentOutOfRangeException(nameof(interval)); } _interval = interval; }
/// <summary> /// SourceMany allows you to get a list of T documents out of OpenSearch, internally it calls into MultiGet() /// <para> /// 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> </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">A list of ids as string</param> /// <param name="index">Optionally override the default inferred indexname for T</param> public static IEnumerable <T> SourceMany <T>(this IOpenSearchClient client, IEnumerable <string> ids, string 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.SourceMany <T>(ids)); }
public SnapshotObservable(IOpenSearchClient opensearchClient, ISnapshotRequest snapshotRequest) { opensearchClient.ThrowIfNull(nameof(opensearchClient)); snapshotRequest.ThrowIfNull(nameof(snapshotRequest)); _opensearchClient = opensearchClient; _snapshotRequest = snapshotRequest; _snapshotRequest.RequestParameters.SetRequestMetaData(RequestMetaDataFactory.SnapshotHelperRequestMetaData()); _snapshotStatusHumbleObject = new SnapshotStatusHumbleObject(opensearchClient, snapshotRequest); _snapshotStatusHumbleObject.Completed += StopTimer; _snapshotStatusHumbleObject.Error += StopTimer; }
/// <summary> /// SourceMany allows you to get a list of T documents out of OpenSearch, internally it calls into MultiGet() /// <para> /// 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> </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">A list of ids as string</param> /// <param name="index">Optionally override the default inferred indexname for T</param> public static async Task <IEnumerable <T> > SourceManyAsync <T>( this IOpenSearchClient client, IEnumerable <string> ids, string index = null, CancellationToken cancellationToken = default ) where T : class { var response = await client.MultiGetAsync(s => s .Index(index) .RequestConfiguration(r => r.ThrowExceptions()) .GetMany <T>(ids, Lookup <T>(index)), cancellationToken) .ConfigureAwait(false); return(response.SourceMany <T>(ids)); }
public BulkAllObservable( IOpenSearchClient client, IBulkAllRequest <T> partitionedBulkRequest, CancellationToken cancellationToken = default ) { _client = client; _partitionedBulkRequest = partitionedBulkRequest; _backOffRetries = _partitionedBulkRequest.BackOffRetries.GetValueOrDefault(CoordinatedRequestDefaults.BulkAllBackOffRetriesDefault); _backOffTime = _partitionedBulkRequest?.BackOffTime?.ToTimeSpan() ?? CoordinatedRequestDefaults.BulkAllBackOffTimeDefault; _bulkSize = _partitionedBulkRequest.Size ?? CoordinatedRequestDefaults.BulkAllSizeDefault; _retryPredicate = _partitionedBulkRequest.RetryDocumentPredicate ?? RetryBulkActionPredicate; _droppedDocumentCallBack = _partitionedBulkRequest.DroppedDocumentCallback ?? DroppedDocumentCallbackDefault; _bulkResponseCallback = _partitionedBulkRequest.BulkResponseCallback; _maxDegreeOfParallelism = _partitionedBulkRequest.MaxDegreeOfParallelism ?? CoordinatedRequestDefaults.BulkAllMaxDegreeOfParallelismDefault; _compositeCancelTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); _compositeCancelToken = _compositeCancelTokenSource.Token; }
/// <summary> /// Returns a dictionary of aliases that point to the specified index, simplified version of /// <see cref="IndicesNamespace.GetAlias(IGetAliasRequest)" />.. /// </summary> /// <param name="index">The index name we want to know aliases of</param> public static async Task <IReadOnlyDictionary <string, AliasDefinition> > GetAliasesPointingToIndexAsync(this IOpenSearchClient client, IndexName index ) { var response = await client.Indices.GetAliasAsync(index, a => a.RequestConfiguration(r => r.ThrowExceptions())).ConfigureAwait(false); return(AliasesPointingToIndex(index, response)); }
/// <summary> /// Returns a dictionary of aliases that point to the specified index, simplified version of /// <see cref="IndicesNamespace.GetAlias(IGetAliasRequest)" />.. /// </summary> /// <param name="index">The index name we want to know aliases of</param> public static IReadOnlyDictionary <string, AliasDefinition> GetAliasesPointingToIndex(this IOpenSearchClient client, IndexName index) { var response = client.Indices.GetAlias(index, a => a.RequestConfiguration(r => r.ThrowExceptions())); return(AliasesPointingToIndex(index, response)); }
/// <summary> /// SourceMany allows you to get a list of T documents out of OpenSearch, internally it calls into MultiGet() /// <para> /// 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> </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">A list of ids as int</param> /// <param name="index">Optionally override the default inferred indexname for T</param> public static IEnumerable <T> SourceMany <T>(this IOpenSearchClient client, IEnumerable <long> ids, string index = null) where T : class => client.SourceMany <T>(ids.Select(i => i.ToString(CultureInfo.InvariantCulture)), index);
/// <summary> /// SourceMany allows you to get a list of T documents out of OpenSearch, internally it calls into MultiGet() /// <para> /// 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> </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">A list of ids as int</param> /// <param name="index">Optionally override the default inferred indexname for T</param> public static Task <IEnumerable <T> > SourceManyAsync <T>( this IOpenSearchClient client, IEnumerable <long> ids, string index = null, CancellationToken cancellationToken = default ) where T : class => client.SourceManyAsync <T>(ids.Select(i => i.ToString(CultureInfo.InvariantCulture)), index, cancellationToken);
/// <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);
public ReindexObservable(IOpenSearchClient client, IConnectionSettingsValues connectionSettings, IReindexRequest <TSource, TSource> reindexRequest, CancellationToken cancellationToken ) : base(client, connectionSettings, reindexRequest, cancellationToken) { }
/// <summary> /// Returns a collection of indices that have the specified alias(es) applied to them. Simplified version of GetAlias. /// </summary> /// <param name="client">The client</param> /// <param name="alias">The alias name(s)</param> public static async Task <IReadOnlyCollection <string> > GetIndicesPointingToAliasAsync(this IOpenSearchClient client, Names alias) { var response = await client.Indices.GetAliasAsync(Indices.All, a => a.Name(alias).RequestConfiguration(r => r.ThrowExceptions())).ConfigureAwait(false); return(IndicesPointingToAlias(client.ConnectionSettings, alias, response)); }