public static IndexQuery GetIndexQueryFromHttpContext(this IHttpContext context, int maxPageSize) { var query = new IndexQuery { Query = context.Request.QueryString["query"] ?? "", Start = context.GetStart(), Cutoff = context.GetCutOff(), CutoffEtag = context.GetCutOffEtag(), PageSize = context.GetPageSize(maxPageSize), SkipTransformResults = context.GetSkipTransformResults(), FieldsToFetch = context.Request.QueryString.GetValues("fetch"), GroupBy = context.Request.QueryString.GetValues("groupBy"), AggregationOperation = context.GetAggregationOperation(), SortedFields = context.Request.QueryString.GetValues("sort") .EmptyIfNull() .Select(x => new SortedField(x)) .ToArray() }; double lat = context.GetLat(), lng = context.GetLng(), radius = context.GetRadius(); if (lat != 0 || lng != 0 || radius != 0) { return(new SpatialIndexQuery(query) { Latitude = lat, Longitude = lng, Radius = radius, }); } return(query); }
public static IndexQuery GetIndexQueryFromHttpContext(this IHttpContext context, int maxPageSize) { var query = new IndexQuery { Query = context.Request.QueryString["query"] ?? "", Start = context.GetStart(), Cutoff = context.GetCutOff(), CutoffEtag = context.GetCutOffEtag(), PageSize = context.GetPageSize(maxPageSize), SkipTransformResults = context.GetSkipTransformResults(), FieldsToFetch = context.Request.QueryString.GetValues("fetch"), GroupBy = context.Request.QueryString.GetValues("groupBy"), DefaultField = context.Request.QueryString["defaultField"], DefaultOperator = string.Equals(context.Request.QueryString["operator"], "AND", StringComparison.OrdinalIgnoreCase) ? QueryOperator.And : QueryOperator.Or, AggregationOperation = context.GetAggregationOperation(), SortedFields = context.Request.QueryString.GetValues("sort") .EmptyIfNull() .Select(x => new SortedField(x)) .ToArray(), HighlightedFields = context.GetHighlightedFields().ToArray(), HighlighterPreTags = context.Request.QueryString.GetValues("preTags"), HighlighterPostTags = context.Request.QueryString.GetValues("postTags"), ResultsTransformer = context.Request.QueryString["resultsTransformer"], QueryInputs = context.ExtractQueryInputs() }; var spatialFieldName = context.Request.QueryString["spatialField"] ?? Constants.DefaultSpatialFieldName; var queryShape = context.Request.QueryString["queryShape"]; SpatialUnits units; bool unitsSpecified = Enum.TryParse(context.Request.QueryString["spatialUnits"], out units); double distanceErrorPct; if (!double.TryParse(context.Request.QueryString["distErrPrc"], NumberStyles.Any, CultureInfo.InvariantCulture, out distanceErrorPct)) { distanceErrorPct = Constants.DefaultSpatialDistanceErrorPct; } SpatialRelation spatialRelation; if (Enum.TryParse(context.Request.QueryString["spatialRelation"], false, out spatialRelation) && !string.IsNullOrWhiteSpace(queryShape)) { return(new SpatialIndexQuery(query) { SpatialFieldName = spatialFieldName, QueryShape = queryShape, RadiusUnitOverride = unitsSpecified ? units : (SpatialUnits?)null, SpatialRelation = spatialRelation, DistanceErrorPercentage = distanceErrorPct, }); } return(query); }
public static IndexQuery GetIndexQueryFromHttpContext(this IHttpContext context, int maxPageSize) { var query = new IndexQuery { Query = context.Request.QueryString["query"] ?? "", Start = context.GetStart(), Cutoff = context.GetCutOff(), CutoffEtag = context.GetCutOffEtag(), PageSize = context.GetPageSize(maxPageSize), SkipTransformResults = context.GetSkipTransformResults(), FieldsToFetch = context.Request.QueryString.GetValues("fetch"), GroupBy = context.Request.QueryString.GetValues("groupBy"), DefaultField = context.Request.QueryString["defaultField"], DefaultOperator = string.Equals(context.Request.QueryString["operator"], "AND", StringComparison.InvariantCultureIgnoreCase) ? QueryOperator.And : QueryOperator.Or, AggregationOperation = context.GetAggregationOperation(), SortedFields = context.Request.QueryString.GetValues("sort") .EmptyIfNull() .Select(x => new SortedField(x)) .ToArray() }; var spatialFieldName = context.Request.QueryString["spatialField"] ?? Constants.DefaultSpatialFieldName; var queryShape = context.Request.QueryString["queryShape"]; double distanceErrorPct; if (!double.TryParse(context.Request.QueryString["distErrPrc"], out distanceErrorPct)) { distanceErrorPct = Constants.DefaultSpatialDistanceErrorPct; } SpatialRelation spatialRelation; if (Enum.TryParse(context.Request.QueryString["spatialRelation"], false, out spatialRelation) && !string.IsNullOrWhiteSpace(queryShape)) { return(new SpatialIndexQuery(query) { SpatialFieldName = spatialFieldName, QueryShape = queryShape, SpatialRelation = spatialRelation, DistanceErrorPercentage = distanceErrorPct, }); } return(query); }