Example #1
0
        private void AppendMinimalQueryString(StringBuilder path, bool appendQuery = true)
        {
            if (string.IsNullOrEmpty(Query) == false && appendQuery)
            {
                path.Append("&query=");
                path.Append(EscapingHelper.EscapeLongDataString(Query));
            }

            if (string.IsNullOrEmpty(DefaultField) == false)
            {
                path.Append("&defaultField=").Append(Uri.EscapeDataString(DefaultField));
            }
            if (DefaultOperator != QueryOperator.Or)
            {
                path.Append("&operator=AND");
            }
            var vars = GetCustomQueryStringVariables();

            if (!string.IsNullOrEmpty(vars))
            {
                path.Append(vars.StartsWith("&") ? vars : ("&" + vars));
            }
        }
Example #2
0
        public string GetQueryString(HttpMethod method)
        {
            var path = new StringBuilder();

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

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

            if (string.IsNullOrEmpty(Query) == false)
            {
                path.Append("&query=").Append(EscapingHelper.EscapeLongDataString(Query));
            }

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

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

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

            FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));

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

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

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

            if (string.IsNullOrWhiteSpace(FacetSetupDoc) == false)
            {
                path.Append("&facetDoc=").Append(FacetSetupDoc);
            }

            if (method == HttpMethod.Get && Facets != null && Facets.Count > 0)
            {
                path.Append("&facets=").Append(GetFacetsAsJson());
            }

            path.Append("&op=facets");

            return(path.ToString());
        }