Hi Lee, On 2/3/14, 1:59 PM, "leevduhl" <ld...@corp.realcomp.com> wrote:
>We have a public property search site that we are looking to replace the >back >end index server on and we are looking at Solr as a possible replacement >(ElasticSearch is another possibility). Both should work equally well. > >One of the key search components of out site is to search on a bounding >box >(rectangle), custom multi-point polygon, and/or a radius from a point. > >It appears that Solr3 and Solr4 both supported spatial searching, but >using >different methods. Also, per this link, >http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4, it appears that >Solr only supports point, rectangle and circle shapes and needs JTS and/or >WKT to support multi-point non non rectangular polygon shapes. Yup. I¹m not sure what you mean by a "multi-point² polygon thoughŠ is that somehow different than a polygon that isn¹t multi-point? All polygons are comprised of at least 3 distinct points (a triangle). > >Our indexed data will included the long/lat values for all property >records. > >If someone can provide sample queries for the following situations, it >would >be appreciated: >- All properties/points that fall within a multi-point polygon (ie: >Polygon >points: Lo1 La1, Lo2 La2, Lo3 La3, Lo4 La4, Lo5 La5, Lo1, La1) mygeorptfieldname:²Intersects(POLYGON((x1 y1, x2 y2, x3 y3, Š, x1 y1)))² Inside of the immediate parenthesis of Intersects is a standard WKT formatted polygon. Note ³x y² order (longitude space latitude). > >- All properties that fall within 1.5 miles (radius) of point: Lo1 La1 Just use Solr¹s standard ³geofilt² query parser: fq={!geofilt}&pt=lat,lon&d=0.021710 I got the distance value by converting miles to kilometers which is what goofily expects (1.5 * 1.60934400061469). > >Other spatial search type functionality that may be targeted included: >- Ability to search within multiple polygons (both intersecting, non >intersecting and combinations No problem for union: Use standard WKT: MULTIPOLYGON or GEOMETRYCOLLECTION. If you want to combine them in interesting ways then you¹re going to have to compute that client-side and send the resulting polygon(s) to Solr (or ElasticSearch). You could use JTS to do that, which has a trove of spatial functionality for such things. I¹m thinking of some day adding some basic operator extensions to the WKT so you don¹t have to do this on the client end. Leveraging JTS server-side it would be particularly easy, but it would also be pretty easy do it as a custom shape aggregate, similar to Spatial4j 0.4¹s ShapeCollection. >- Ability to search for properties that fall outside of a polygon You could use ³IsDisjointTo" (instead of ³Intersects²) but you¹ll generally get faster results by negating intersects. For an example, simply precede the first polygonal example with a ³NOT ³. > >Thanks >Lee ~ David