/// <summary> /// Create a spatial filter parameter /// </summary> /// <param name="functionType">Function used in the spatial filter</param> /// <param name="expression">Expression used to find the property name</param> /// <param name="centerPoint">Center point to spatial filter</param> /// <param name="distance">Distance from the center point</param> public Spatial(SolrSpatialFunctionType functionType, Expression <Func <TDocument, object> > expression, GeoCoordinate centerPoint, decimal distance) { Checker.IsNull(expression); this.FunctionType = functionType; this.Expression = expression; this.CenterPoint = centerPoint; this.Distance = distance; }
/// <summary> /// Get spatial formule /// </summary> /// <param name="functionType">Spatial function to use</param> /// <param name="fieldName">Field name</param> /// <param name="centerPoint">Center point information</param> /// <param name="distance">Distance</param> /// <returns></returns> public static string GetSolrSpatialFormule(SolrSpatialFunctionType functionType, string fieldName, GeoCoordinate centerPoint, decimal distance) { return(string.Format( "{{!{0} sfield={1} pt={2} d={3}}}", functionType.ToString().ToLower(), fieldName, $"{centerPoint.Latitude.ToString("G", CultureInfo.InvariantCulture)},{centerPoint.Longitude.ToString("G", CultureInfo.InvariantCulture)}", distance.ToString("G", CultureInfo.InvariantCulture))); }
/// <summary> /// Configure current instance /// </summary> /// <param name="aliasName">Name of the alias added in the query</param> /// <param name="functionType">Function used in the spatial filter</param> /// <param name="expression">Expression used to find the property name</param> /// <param name="centerPoint">Center point to spatial filter</param> /// <param name="distance">Distance from the center point</param> /// <param name="sortType">Sort type of the result of the facet</param> /// <param name="excludes">List of tags to exclude in facet calculation</param> public IFacetSpatialParameter <TDocument> Configure(string aliasName, SolrSpatialFunctionType functionType, Expression <Func <TDocument, object> > expression, GeoCoordinate centerPoint, decimal distance, FacetSortType?sortType = null, params string[] excludes) { this.AliasName = aliasName; this.FunctionType = functionType; this.Expression = expression; this.CenterPoint = centerPoint; this.Distance = distance; this.SortType = sortType; this.Excludes = excludes; return(this); }
ISpatialFilterParameter <TDocument> ISearchParameterBuilder <TDocument> .SpatialFilter(Expression <Func <TDocument, object> > expression, SolrSpatialFunctionType functionType, GeoCoordinate centerPoint, decimal distance) { throw new NotImplementedException(); }
/// <summary> /// Create a query field parameter /// </summary> /// <param name="expression">Expression used to find the property name</param> /// <param name="functionType">Function used in the spatial filter</param> /// <param name="centerPoint">Center point to spatial filter</param> /// <param name="distance">Distance from the center point</param> public ISpatialFilterParameter <TDocument> SpatialFilter(Expression <Func <TDocument, object> > expression, SolrSpatialFunctionType functionType, GeoCoordinate centerPoint, decimal distance) { return(this .Engine .GetService <ISpatialFilterParameter <TDocument> >() .Configure(expression, functionType, centerPoint, distance)); }
/// <summary> /// Configure current instance /// </summary> /// <param name="expression">Expression used to find the property name</param> /// <param name="functionType">Function used in the spatial filter</param> /// <param name="centerPoint">Center point to spatial filter</param> /// <param name="distance">Distance from the center point</param> public ISpatialFilterParameter <TDocument> Configure(Expression <Func <TDocument, object> > expression, SolrSpatialFunctionType functionType, GeoCoordinate centerPoint, decimal distance) { Checker.IsNull(expression); this.FunctionType = functionType; this.Expression = expression; this.CenterPoint = centerPoint; this.Distance = distance; return(this); }
/// <summary> /// Create a query field parameter /// </summary> /// <param name="expression">Expression used to find the property name</param> /// <param name="functionType">Function used in the spatial filter</param> /// <param name="centerPoint">Center point to spatial filter</param> /// <param name="distance">Distance from the center point</param> public static ISolrSearch <TDocument> SpatialFilter <TDocument>(this ISolrSearch <TDocument> search, Expression <Func <TDocument, object> > expression, SolrSpatialFunctionType functionType, GeoCoordinate centerPoint, decimal distance) where TDocument : IDocument { search.Add(search.GetBuilder().SpatialFilter(expression, functionType, centerPoint, distance)); return(search); }