Ejemplo n.º 1
0
        public StreamCommand CreateRequest(IRavenQueryInspector query)
        {
            var ravenQueryInspector = query;
            var indexQuery          = ravenQueryInspector.GetIndexQuery(false);

            if (indexQuery.WaitForNonStaleResults || indexQuery.WaitForNonStaleResultsAsOfNow)
            {
                throw new NotSupportedException(
                          "Since Stream() does not wait for indexing (by design), streaming query with WaitForNonStaleResults is not supported.");
            }
            _session.IncrementRequestCount();
            var index = ravenQueryInspector.IndexQueried;

            if (string.IsNullOrEmpty(index))
            {
                throw new ArgumentException("Key cannot be null or empty index");
            }
            string path;

            if (indexQuery.Query != null && indexQuery.Query.Length > _session.Conventions.MaxLengthOfQueryUsingGetUrl)
            {
                path = indexQuery.GetIndexQueryUrl(index, "streams/queries", includePageSizeEvenIfNotExplicitlySet: false, includeQuery: false);
            }
            else
            {
                path = indexQuery.GetIndexQueryUrl(index, "streams/queries", includePageSizeEvenIfNotExplicitlySet: false);
            }

            return(new StreamCommand()
            {
                Url = path,
            });
        }
Ejemplo n.º 2
0
        private static void SetSuggestionQueryFieldAndTerm(IRavenQueryInspector queryInspector, SuggestionQuery query)
        {
            var lastEqualityTerm = queryInspector.GetLastEqualityTerm();

            if (lastEqualityTerm.Key == null)
            {
                throw new InvalidOperationException("Could not suggest on a query that doesn't have a single equality check");
            }

            query.Field = lastEqualityTerm.Key;
            query.Term  = lastEqualityTerm.Value;
        }
Ejemplo n.º 3
0
        private static void SetSuggestionQueryFieldAndTerm(IRavenQueryInspector queryInspector, SuggestionQuery query, bool isAsync = false)
        {
            if (string.IsNullOrEmpty(query.Field) == false && string.IsNullOrEmpty(query.Term) == false)
            {
                return;
            }

            var lastEqualityTerm = queryInspector.GetLastEqualityTerm(isAsync);

            if (lastEqualityTerm.Key == null)
            {
                throw new InvalidOperationException("Could not suggest on a query that doesn't have a single equality check");
            }

            query.Field = lastEqualityTerm.Key;
            query.Term  = lastEqualityTerm.Value;
        }