Example #1
0
        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;
        }
        /// <inheritdoc/>
        /// <param name="scrollSource">The scroll operation yielding the source documents for the reindex operation</param>
        /// <param name="map">A function that converts from a source document to a target document</param>
        /// <param name="bulkAllTarget">A factory that instantiates the bulk all operation over the lazy stream of search result hits</param>
        public ReindexRequest(IScrollAllRequest scrollSource, Func <TSource, TTarget> map, Func <IEnumerable <IHitMetadata <TTarget> >, IBulkAllRequest <IHitMetadata <TTarget> > > bulkAllTarget)
        {
            scrollSource.ThrowIfNull(nameof(scrollSource), "scrollSource must be set in order to get the source of a Reindex operation");
            bulkAllTarget.ThrowIfNull(nameof(bulkAllTarget), "bulkAllTarget must set in order to get the target of a Reindex operation");
            map.ThrowIfNull(nameof(map), "map must be set to know how to take TSource and transform it into TTarget");

            var i = (IReindexRequest <TSource, TTarget>) this;

            i.ScrollAll = scrollSource;
            i.BulkAll   = bulkAllTarget;
            i.Map       = map;
        }
 public ScrollAllObservable(
     IElasticClient client,
     IScrollAllRequest scrollAllRequest,
     CancellationToken cancellationToken = default(CancellationToken)
     )
 {
     _scrollAllRequest = scrollAllRequest;
     _searchRequest    = scrollAllRequest?.Search ?? new SearchRequest <T>();
     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;
 }
 /// <inheritdoc />
 public IObservable <IScrollAllResponse <T> > ScrollAll <T>(IScrollAllRequest request,
                                                            CancellationToken cancellationToken = default(CancellationToken)
                                                            )
     where T : class =>
 new ScrollAllObservable <T>(this, request, cancellationToken);
 public IObservable <ScrollAllResponse <T> > ScrollAll <T>(IScrollAllRequest request, CancellationToken cancellationToken = new CancellationToken()) where T : class
 {
     throw new NotImplementedException();
 }