Пример #1
0
        public override async Task <IndexEntriesQueryResult> ExecuteIndexEntriesQuery(IndexQueryServerSide query, QueryOperationContext queryContext, long?existingResultEtag, OperationCancelToken token)
        {
            var index = await MatchIndex(query, false, null, token.Token);

            if (index == null)
            {
                IndexDoesNotExistException.ThrowFor(query.Metadata.CollectionName);
            }

            queryContext.WithIndex(index);

            if (existingResultEtag.HasValue)
            {
                var etag = index.GetIndexEtag(queryContext, query.Metadata);
                if (etag == existingResultEtag)
                {
                    return(IndexEntriesQueryResult.NotModifiedResult);
                }
            }

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token))
            {
                return(await index.IndexEntries(query, queryContext, token));
            }
        }
Пример #2
0
        public async Task <FacetedQueryResult> ExecuteFacetedQuery(IndexQueryServerSide query, long?existingResultEtag, QueryOperationContext queryContext, OperationCancelToken token)
        {
            if (query.Metadata.IsDynamic)
            {
                throw new InvalidQueryException("Facet query must be executed against static index.", query.Metadata.QueryText, query.QueryParameters);
            }

            var fq = FacetQuery.Create(queryContext.Documents, query);

            var index = GetIndex(query.Metadata.IndexName);

            queryContext.WithIndex(index);

            if (existingResultEtag.HasValue)
            {
                var etag = index.GetIndexEtag(queryContext, query.Metadata) ^ fq.FacetsEtag;
                if (etag == existingResultEtag)
                {
                    return(FacetedQueryResult.NotModifiedResult);
                }
            }

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token))
            {
                return(await index.FacetedQuery(fq, queryContext, token));
            }
        }
Пример #3
0
        public TermsQueryResultServerSide ExecuteGetTermsQuery(string indexName, string field, string fromValue, long?existingResultEtag, int pageSize, QueryOperationContext queryContext, OperationCancelToken token, out Index index)
        {
            ObjectDisposedException lastException = null;

            for (var i = 0; i < NumberOfRetries; i++)
            {
                try
                {
                    index = GetIndex(indexName);

                    queryContext.WithIndex(index);

                    var etag = index.GetIndexEtag(queryContext, null);
                    if (etag == existingResultEtag)
                    {
                        return(TermsQueryResultServerSide.NotModifiedResult);
                    }

                    return(index.GetTerms(field, fromValue, pageSize, queryContext, token));
                }
                catch (ObjectDisposedException e)
                {
                    if (Database.DatabaseShutdown.IsCancellationRequested)
                    {
                        throw;
                    }

                    lastException = e;
                }
            }

            throw CreateRetriesFailedException(lastException);
        }
Пример #4
0
        public override async Task <SuggestionQueryResult> ExecuteSuggestionQuery(IndexQueryServerSide query, QueryOperationContext queryContext, long?existingResultEtag, OperationCancelToken token)
        {
            var index = await MatchIndex(query, true, null, token.Token);

            queryContext.WithIndex(index);

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token))
            {
                return(await ExecuteSuggestion(query, index, queryContext, existingResultEtag, token));
            }
        }
Пример #5
0
        public override async Task <IOperationResult> ExecutePatchQuery(IndexQueryServerSide query, QueryOperationOptions options, PatchRequest patch, BlittableJsonReaderObject patchArgs, QueryOperationContext queryContext, Action <IOperationProgress> onProgress, OperationCancelToken token)
        {
            var index = await MatchIndex(query, true, null, token.Token);

            queryContext.WithIndex(index);

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token))
            {
                return(await ExecutePatch(query, index, options, patch, patchArgs, queryContext, onProgress, token));
            }
        }
Пример #6
0
        public override async Task ExecuteStreamIndexEntriesQuery(IndexQueryServerSide query, QueryOperationContext queryContext, HttpResponse response, IStreamQueryResultWriter <BlittableJsonReaderObject> writer, OperationCancelToken token)
        {
            var index = GetIndex(query.Metadata.IndexName);

            queryContext.WithIndex(index);

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token, true))
            {
                await index.StreamIndexEntriesQuery(response, writer, query, queryContext, token);
            }
        }
Пример #7
0
        public override async Task <IOperationResult> ExecuteDeleteQuery(IndexQueryServerSide query, QueryOperationOptions options, QueryOperationContext queryContext, Action <IOperationProgress> onProgress, OperationCancelToken token)
        {
            var index = GetIndex(query.Metadata.IndexName);

            queryContext.WithIndex(index);

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token))
            {
                return(await ExecuteDelete(query, index, options, queryContext, onProgress, token));
            }
        }
Пример #8
0
        public override async Task ExecuteStreamQuery(IndexQueryServerSide query, QueryOperationContext queryContext, HttpResponse response, IStreamQueryResultWriter <Document> writer,
                                                      OperationCancelToken token)
        {
            var index = await MatchIndex(query, true, customStalenessWaitTimeout : TimeSpan.FromSeconds(60), token.Token);

            queryContext.WithIndex(index);

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token, isStreaming: true))
            {
                await index.StreamQuery(response, writer, query, queryContext, token);
            }
        }
Пример #9
0
        public override async Task <IndexEntriesQueryResult> ExecuteIndexEntriesQuery(IndexQueryServerSide query, QueryOperationContext queryContext, long?existingResultEtag, OperationCancelToken token)
        {
            var index = GetIndex(query.Metadata.IndexName);

            queryContext.WithIndex(index);

            if (existingResultEtag.HasValue)
            {
                var etag = index.GetIndexEtag(queryContext, query.Metadata);
                if (etag == existingResultEtag)
                {
                    return(IndexEntriesQueryResult.NotModifiedResult);
                }
            }

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token))
            {
                return(await index.IndexEntries(query, queryContext, token));
            }
        }
Пример #10
0
        public override async Task <DocumentQueryResult> ExecuteQuery(IndexQueryServerSide query, QueryOperationContext queryContext, long?existingResultEtag, OperationCancelToken token)
        {
            Index index;

            using (query.Timings?.For(nameof(QueryTimingsScope.Names.Optimizer)))
                index = await MatchIndex(query, true, null, token.Token);

            queryContext.WithIndex(index);

            if (query.Metadata.HasOrderByRandom == false && existingResultEtag.HasValue)
            {
                var etag = index.GetIndexEtag(queryContext, query.Metadata);
                if (etag == existingResultEtag)
                {
                    return(DocumentQueryResult.NotModifiedResult);
                }
            }

            using (QueryRunner.MarkQueryAsRunning(index.Name, query, token))
            {
                return(await index.Query(query, queryContext, token));
            }
        }