示例#1
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");
            }
        }