Esempio n. 1
0
        public void AppendQueryString(StringBuilder path)
        {
            path
            .Append("?query=");

            path.Append(Uri.EscapeUriString(Uri.EscapeDataString(Query ?? "")))
            .Append("&start=").Append(Start)
            .Append("&pageSize=").Append(PageSize)
            .Append("&aggregation=").Append(AggregationOperation);
            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            GroupBy.ApplyIfNotNull(field => path.Append("&groupBy=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));

            if (Cutoff != null)
            {
                var cutOffAsString =
                    Uri.EscapeUriString(Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture)));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag.Value.ToString());
            }
            var vars = GetCustomQueryStringVariables();

            if (!string.IsNullOrEmpty(vars))
            {
                path.Append(vars.StartsWith("&") ? vars : ("&" + vars));
            }
        }
Esempio n. 2
0
        public void AppendQueryString(StringBuilder path)
        {
            path.Append("?");

            AppendMinimalQueryString(path);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            path.Append("&pageSize=").Append(PageSize);


            if (AggregationOperation != AggregationOperation.None)
            {
                path.Append("&aggregation=").Append(AggregationOperation);
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            GroupBy.ApplyIfNotNull(field => path.Append("&groupBy=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));



            if (SkipTransformResults)
            {
                path.Append("&skipTransformResults=true");
            }

            if (Cutoff != null)
            {
                var cutOffAsString =
                    Uri.EscapeUriString(Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture)));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag.Value.ToString());
            }

            this.HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            this.HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            this.HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));



            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }
        }
Esempio n. 3
0
        public void AppendQueryString(StringBuilder path)
        {
            path
            .Append("?query=");

            path.Append(Uri.EscapeUriString(Uri.EscapeDataString(Query ?? "")))
            .Append("&start=").Append(Start)
            .Append("&pageSize=").Append(PageSize)
            .Append("&aggregation=").Append(AggregationOperation);
            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            GroupBy.ApplyIfNotNull(field => path.Append("&groupBy=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));

            if (string.IsNullOrEmpty(DefaultField) == false)
            {
                path.Append("&defaultField=").Append(Uri.EscapeDataString(DefaultField));
            }

            if (DefaultOperator != QueryOperator.Or)
            {
                path.Append("&operator=AND");
            }

            if (SkipTransformResults)
            {
                path.Append("&skipTransformResults=true");
            }

            if (Cutoff != null)
            {
                var cutOffAsString =
                    Uri.EscapeUriString(Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture)));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag.Value.ToString());
            }
            var vars = GetCustomQueryStringVariables();

            if (!string.IsNullOrEmpty(vars))
            {
                path.Append(vars.StartsWith("&") ? vars : ("&" + vars));
            }

            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the index query URL.
        /// </summary>
        /// <param name="operationUrl">The operation URL.</param>
        /// <param name="index">The index.</param>
        /// <param name="operationName">Name of the operation.</param>
        /// <returns></returns>
        public string GetIndexQueryUrl(string operationUrl, string index, string operationName)
        {
            if (operationUrl.EndsWith("/"))
            {
                operationUrl = operationUrl.Substring(0, operationUrl.Length - 1);
            }
            var path = new StringBuilder()
                       .Append(operationUrl)
                       .Append("/")
                       .Append(operationName)
                       .Append("/")
                       .Append(index)
                       .Append("?query=").Append(Uri.EscapeUriString(Uri.EscapeDataString(Query ?? "")))
                       .Append("&start=").Append(Start)
                       .Append("&pageSize=").Append(PageSize)
                       .Append("&aggregation=").Append(AggregationOperation);

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            GroupBy.ApplyIfNotNull(field => path.Append("&groupBy=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));

            if (Cutoff != null)
            {
                var cutOffAsString =
                    Uri.EscapeUriString(Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture)));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            var vars = GetCustomQueryStringVariables();

            if (!string.IsNullOrEmpty(vars))
            {
                path.Append(vars.StartsWith("&") ? vars : ("&" + vars));
            }

            return(path.ToString());
        }
Esempio n. 5
0
        public void AppendQueryString(StringBuilder path, bool includePageSizeEvenIfNotExplicitlySet = true, bool includeQuery = true)
        {
            path.Append("?");

            AppendMinimalQueryString(path, includeQuery);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            if (includePageSizeEvenIfNotExplicitlySet || PageSizeSet)
            {
                path.Append("&pageSize=").Append(PageSize);
            }

            if (AllowMultipleIndexEntriesForSameDocumentToResultTransformer)
            {
                path.Append("&allowMultipleIndexEntriesForSameDocumentToResultTransformer=true");
            }

            if (IsDistinct)
            {
                path.Append("&distinct=true");
            }

            if (ShowTimings)
            {
                path.Append("&showTimings=true");
            }
            if (SkipDuplicateChecking)
            {
                path.Append("&skipDuplicateChecking=true");
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            Includes.ApplyIfNotNull(include => path.AppendFormat("&include={0}", Uri.EscapeDataString(include)));

            DynamicMapReduceFields.ApplyIfNotNull(field => path.Append("&mapReduce=")
                                                  .Append(Uri.EscapeDataString(field.Name))
                                                  .Append("-")
                                                  .Append(field.OperationType)
                                                  .Append("-")
                                                  .Append(field.IsGroupBy));

            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));

            if (string.IsNullOrEmpty(Transformer) == false)
            {
                path.AppendFormat("&transformer={0}", Uri.EscapeDataString(Transformer));
            }

            if (TransformerParameters != null)
            {
                foreach (var input in TransformerParameters)
                {
                    path.AppendFormat("&tp-{0}={1}", input.Key, input.Value);
                }
            }

            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag);
            }

            if (WaitForNonStaleResultsAsOfNow)
            {
                path.Append("&waitForNonStaleResultsAsOfNow=true");
            }

            if (WaitForNonStaleResultsTimeout != null)
            {
                path.AppendLine("&waitForNonStaleResultsTimeout=" + WaitForNonStaleResultsTimeout);
            }

            HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));

            if (string.IsNullOrEmpty(HighlighterKeyName) == false)
            {
                path.AppendFormat("&highlighterKeyName={0}", Uri.EscapeDataString(HighlighterKeyName));
            }

            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }

            if (ExplainScores)
            {
                path.Append("&explainScores=true");
            }
        }
Esempio n. 6
0
        public void AppendQueryString(StringBuilder path, bool includePageSizeEvenIfNotExplicitlySet = true, bool includeQuery = true)
        {
            path.Append("?");

            AppendMinimalQueryString(path, includeQuery);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            if (includePageSizeEvenIfNotExplicitlySet || PageSizeSet)
            {
                path.Append("&pageSize=").Append(PageSize);
            }


            if (AllowMultipleIndexEntriesForSameDocumentToResultTransformer)
            {
                path.Append("&allowMultipleIndexEntriesForSameDocumentToResultTransformer=true");
            }

            if (IsDistinct)
            {
                path.Append("&distinct=true");
            }

            if (ShowTimings)
            {
                path.Append("&showTimings=true");
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));
            SortHints.ApplyIfNotNull(hint => path.AppendFormat("&SortHint{2}{0}={1}", Uri.EscapeDataString(hint.Key), hint.Value, hint.Key.StartsWith("-") ? string.Empty : "-"));

            if (string.IsNullOrEmpty(ResultsTransformer) == false)
            {
                path.AppendFormat("&resultsTransformer={0}", Uri.EscapeDataString(ResultsTransformer));
            }

            if (TransformerParameters != null)
            {
                foreach (var input in TransformerParameters)
                {
                    path.AppendFormat("&tp-{0}={1}", input.Key, input.Value);
                }
            }

            if (Cutoff != null)
            {
                var cutOffAsString = Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag);
            }
            if (WaitForNonStaleResultsAsOfNow)
            {
                path.Append("&waitForNonStaleResultsAsOfNow=true");
            }

            HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));

            if (string.IsNullOrEmpty(HighlighterKeyName) == false)
            {
                path.AppendFormat("&highlighterKeyName={0}", Uri.EscapeDataString(HighlighterKeyName));
            }

            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }

            if (ExplainScores)
            {
                path.Append("&explainScores=true");
            }
        }
Esempio n. 7
0
        public void AppendQueryString(StringBuilder path, bool includePageSizeEvenIfNotExplicitlySet = true)
        {
            path.Append("?");

            AppendMinimalQueryString(path);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            if (includePageSizeEvenIfNotExplicitlySet || PageSizeSet)
            {
                path.Append("&pageSize=").Append(PageSize);
            }


            if (AggregationOperation != AggregationOperation.None)
            {
                path.Append("&aggregation=").Append(AggregationOperation);
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            GroupBy.ApplyIfNotNull(field => path.Append("&groupBy=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));



            if (SkipTransformResults)
            {
                path.Append("&skipTransformResults=true");
            }

            if (AllowMultipleIndexEntriesForSameDocumentToResultTransformer)
            {
                path.Append("&allowMultipleIndexEntriesForSameDocumentToResultTransformer=true");
            }


            if (string.IsNullOrEmpty(ResultsTransformer) == false)
            {
                path.AppendFormat("&resultsTransformer={0}", Uri.EscapeDataString(ResultsTransformer));
            }

            if (QueryInputs != null)
            {
                foreach (var input in QueryInputs)
                {
                    path.AppendFormat("&qp-{0}={1}", input.Key, input.Value);
                }
            }

            if (Cutoff != null)
            {
                var cutOffAsString = Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag);
            }

            this.HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            this.HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            this.HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));



            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }
        }
Esempio n. 8
0
        public void AppendQueryString(StringBuilder path, bool includePageSizeEvenIfNotExplicitlySet = true, bool includeQuery = true)
        {
            path.Append("?");

            AppendMinimalQueryString(path, includeQuery);

            if (Start != 0)
            {
                path.Append("&start=").Append(Start);
            }

            if (includePageSizeEvenIfNotExplicitlySet || PageSizeSet)
            {
                path.Append("&pageSize=").Append(PageSize);
            }


            if (IsDistinct)
            {
                path.Append("&distinct=true");
            }

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
            SortedFields.ApplyIfNotNull(
                field => path.Append("&sort=").Append(field.Descending ? "-" : "").Append(Uri.EscapeDataString(field.Field)));



            if (SkipTransformResults)
            {
                path.Append("&skipTransformResults=true");
            }

            if (string.IsNullOrEmpty(ResultsTransformer) == false)
            {
                path.AppendFormat("&resultsTransformer={0}", Uri.EscapeDataString(ResultsTransformer));
            }

            if (QueryInputs != null)
            {
                foreach (var input in QueryInputs)
                {
                    path.AppendFormat("&qp-{0}={1}", input.Key, input.Value);
                }
            }

            if (Cutoff != null)
            {
                var cutOffAsString = Uri.EscapeDataString(Cutoff.Value.ToString("o", CultureInfo.InvariantCulture));
                path.Append("&cutOff=").Append(cutOffAsString);
            }
            if (CutoffEtag != null)
            {
                path.Append("&cutOffEtag=").Append(CutoffEtag);
            }
            if (WaitForNonStaleResultsAsOfNow)
            {
                path.Append("&waitForNonStaleResultsAsOfNow=true");
            }

            HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
            HighlighterPreTags.ApplyIfNotNull(tag => path.Append("&preTags=").Append(tag));
            HighlighterPostTags.ApplyIfNotNull(tag => path.Append("&postTags=").Append(tag));

            if (DebugOptionGetIndexEntries)
            {
                path.Append("&debug=entries");
            }

            if (ExplainScores)
            {
                path.Append("&explainScores=true");
            }
        }