Example #1
0
        /// <summary>
        /// Query the facets results for this query using the specified facet document with the given start and pageSize
        /// </summary>
        /// <param name="facetSetupDoc">Name of the FacetSetup document</param>
        /// <param name="start">Start index for paging</param>
        /// <param name="pageSize">Paging PageSize. If set, overrides Facet.MaxResults</param>
        public static FacetResults ToFacets <T>(this IDocumentQuery <T> query, string facetSetupDoc, int start = 0, int?pageSize = null)
        {
            var indexQuery    = query.GetIndexQuery(isAsync: false);
            var documentQuery = ((DocumentQuery <T>)query);

            return(documentQuery.DatabaseCommands.GetFacets(documentQuery.IndexQueried, indexQuery, facetSetupDoc, start, pageSize));
        }
        public IEnumerator <StreamResult <T> > Stream <T>(IDocumentQuery <T> query)
        {
            var streamOperation = new StreamOperation(this);
            var command         = streamOperation.CreateRequest(query.GetIndexQuery());

            RequestExecutor.Execute(command, Context, sessionInfo: _sessionInfo);
            var result = streamOperation.SetResult(command.Result);

            return(YieldResults(query, result));
        }
Example #3
0
        private IEnumerator <TimeSeriesStreamResult <T> > StreamTimeSeriesInternal <T>(IDocumentQuery <T> query) where T : ITimeSeriesQueryStreamResult, new()
        {
            var streamOperation = new StreamOperation(this);
            var command         = streamOperation.CreateRequest(query.GetIndexQuery());

            RequestExecutor.Execute(command, Context, sessionInfo: _sessionInfo);
            var result = streamOperation.SetResultForTimeSeries(command.Result);

            return(YieldTimeSeriesResults(query, result));
        }
Example #4
0
        /// <summary>
        /// Lazily Query the facets results for this query using the specified facet document with the given start and pageSize
        /// </summary>
        /// <param name="facetSetupDoc">Name of the FacetSetup document</param>
        /// <param name="start">Start index for paging</param>
        /// <param name="pageSize">Paging PageSize. If set, overrides Facet.MaxResults</param>
        public static Lazy <FacetResults> ToFacetsLazy <T>(this IDocumentQuery <T> query, string facetSetupDoc, int start = 0, int?pageSize = null)
        {
            var indexQuery    = query.GetIndexQuery(isAsync: false);
            var documentQuery = ((DocumentQuery <T>)query);

            var lazyOperation = new LazyFacetsOperation(documentQuery.IndexQueried, facetSetupDoc, indexQuery, start, pageSize);

            var documentSession = ((DocumentSession)documentQuery.Session);

            return(documentSession.AddLazyOperation <FacetResults>(lazyOperation, null));
        }
        public void StreamInto <T>(IDocumentQuery <T> query, Stream output)
        {
            var streamOperation = new StreamOperation(this);
            var command         = streamOperation.CreateRequest(query.GetIndexQuery());

            RequestExecutor.Execute(command, Context, sessionInfo: _sessionInfo);

            using (command.Result.Response)
                using (command.Result.Stream)
                {
                    command.Result.Stream.CopyTo(output);
                }
        }
Example #6
0
        public IEnumerator <StreamResult <T> > Stream <T>(IDocumentQuery <T> query, out StreamQueryStatistics streamQueryStats)
        {
            var stats           = new StreamQueryStatistics();
            var streamOperation = new StreamOperation(this, stats);
            var command         = streamOperation.CreateRequest(query.GetIndexQuery());

            RequestExecutor.Execute(command, Context, sessionInfo: SessionInfo);
            using (var result = streamOperation.SetResult(command.Result))
            {
                streamQueryStats = stats;

                return(YieldResults(query, result));
            }
        }
Example #7
0
        public IEnumerator <StreamResult <T> > Stream <T>(IDocumentQuery <T> query, out QueryHeaderInformation queryHeaderInformation)
        {
            var  indexQuery = query.GetIndexQuery(false);
            bool waitForNonStaleResultsWasSetGloably = this.Advanced.DocumentStore.Conventions.DefaultQueryingConsistency == ConsistencyOptions.AlwaysWaitForNonStaleResultsAsOfLastWrite;

            if (!waitForNonStaleResultsWasSetGloably && (indexQuery.WaitForNonStaleResults || indexQuery.WaitForNonStaleResultsAsOfNow))
            {
                throw new NotSupportedException(
                          "Since Stream() does not wait for indexing (by design), streaming query with WaitForNonStaleResults is not supported.");
            }
            IncrementRequestCount();
            var enumerator = DatabaseCommands.StreamQuery(query.IndexQueried, indexQuery, out queryHeaderInformation);

            return(YieldQuery(query, enumerator));
        }
        private IEnumerator <TimeSeriesStreamResult <T> > StreamTimeSeriesInternal <T>(IDocumentQuery <T> query, out StreamQueryStatistics streamQueryStats) where T : ITimeSeriesQueryStreamResult, new()
        {
            var stats           = new StreamQueryStatistics();
            var streamOperation = new StreamOperation(this, stats);
            var command         = streamOperation.CreateRequest(query.GetIndexQuery());

            RequestExecutor.Execute(command, Context, sessionInfo: _sessionInfo);
            streamOperation.EnsureIsAcceptable(query.IndexName, command.Result);

            var result = streamOperation.SetResultForTimeSeries(command.Result);

            streamQueryStats = stats;

            return(YieldTimeSeriesResults(query, result));
        }
Example #9
0
        /// <summary>
        /// Lazily Query the facets results for this query using the specified list of facets with the given start and pageSize
        /// </summary>
        /// <param name="facets">List of facets</param>
        /// <param name="start">Start index for paging</param>
        /// <param name="pageSize">Paging PageSize. If set, overrides Facet.MaxResults</param>
        public static Lazy <FacetResults> ToFacetsLazy <T>(this IDocumentQuery <T> query, IEnumerable <Facet> facets, int start = 0, int?pageSize = null)
        {
            var facetsList = facets.ToList();

            if (!facetsList.Any())
            {
                throw new ArgumentException("Facets must contain at least one entry", "facets");
            }

            var indexQuery    = query.GetIndexQuery(isAsync: false);
            var documentQuery = ((DocumentQuery <T>)query);

            var lazyOperation = new LazyFacetsOperation(documentQuery.IndexQueried, facetsList, indexQuery, start, pageSize);

            var documentSession = ((DocumentSession)documentQuery.Session);

            return(documentSession.AddLazyOperation <FacetResults>(lazyOperation, null));
        }