Return-Path: Delivered-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Received: (qmail 16947 invoked from network); 30 Sep 2010 22:19:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Sep 2010 22:19:49 -0000 Received: (qmail 16994 invoked by uid 500); 30 Sep 2010 22:19:49 -0000 Delivered-To: apmail-lucene-solr-commits-archive@lucene.apache.org Received: (qmail 16947 invoked by uid 500); 30 Sep 2010 22:19:48 -0000 Mailing-List: contact solr-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-dev@lucene.apache.org Delivered-To: mailing list solr-commits@lucene.apache.org Received: (qmail 16940 invoked by uid 99); 30 Sep 2010 22:19:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Sep 2010 22:19:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Sep 2010 22:19:45 +0000 Received: from eosnew.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 0965D2D3 for ; Thu, 30 Sep 2010 22:19:15 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Thu, 30 Sep 2010 22:19:15 -0000 Message-ID: <20100930221915.58926.93119@eosnew.apache.org> Subject: =?utf-8?q?=5BSolr_Wiki=5D_Update_of_=22SpatialSearch=22_by_YonikSeeley?= X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for chan= ge notification. The "SpatialSearch" page has been changed by YonikSeeley. The comment on this change is: move in-progress docs to a dev page. http://wiki.apache.org/solr/SpatialSearch?action=3Ddiff&rev1=3D36&rev2=3D37 -------------------------------------------------- = = =3D Further Details - Under Development =3D + SpatialSearchDev = - =3D=3D=3D=3D Example =3D=3D=3D=3D - {{{ - - ... - - }}} - =3D=3D=3D LatLonType =3D=3D=3D - The !LatLonType combines a latitude/longitude point. All input is interp= reted as latitude then longitude. The LatLonType is similar to !PointType,= but it does distance calculations based on Great Circle (haversine) and is= only two dimensional (lat/lon). - = - =3D=3D=3D=3D Example =3D=3D=3D=3D - {{{ - - ... - - }}} - =3D=3D=3D Geohash =3D=3D=3D - A geohash is a way of encoding lat/lon into a single field as a String. = As of https://issues.apache.org/jira/browse/SOLR-1586, it will be possible = to create a geohash via FieldType, simply by passing in a Point (lat,lon). = Solr will do the work of converting the point to a geohash. - = - See http://www.geohash.org and http://en.wikipedia.org/wiki/Geohash - = - =3D=3D=3D=3D Example =3D=3D=3D=3D - {{{ - - ... - - }}} - =3D Indexing =3D - Indexing is handled by the various !FieldType instances in the schema. A= t the most basic, the user can represent their own spatial data using ints,= floats or doubles. Beyond that, the !PointType, !GeoHashField and !LatLon= Type can be used to index spatial information automatically. - = - When indexing, the format is something like: - = - {{{ - 12.34,-123.45 - }}} - (It can vary based on the number of values. When using a !LatLonType or = a !GeoHashField, it is always latitude, then longitude. - = - =3D Filtering =3D - There are several different ways to filter in spatial search: - = - 1. By Range Query, as in {{{fq=3Dlat:[-23.0 TO -79.5] AND lon:[56.3 TO 6= 0.3]}}} -- Already implemented - 1. By the Spatial Filter QParser (!SpatialQParser) - e.g. {!sfilt fl=3D= location}&pt=3D49.32,-79.0&d=3D20 - 1. Using the "frange" QParser, as in {{{fq=3D{!frange l=3D0 u=3D400}hsin= (0.57, -1.3, lat_rad, lon_rad, 3963.205)}}} - = - In practice, for those using Solr's field types above, the Spatial Filter= !QParser will automatically make the correct decision about how best to fi= lter. If an application needs a specific type of filtering for performance= or other needs, the best bet is to extend the !FieldType in question with = your own needs. - = - =3D=3D Spatial Filter QParser =3D=3D - See https://issues.apache.org/jira/browse/SOLR-1568. - = - ''NOTE: Depending on the !FieldType, different calculations for distance = will be applied''. For instance, the !PointType uses a rectangular coordin= ate system and uses the Euclidean distance while !LatLonType uses Haversine= by default. - = - See !SpatialFilterTest for examples of the various points. - = - The following parameters are supported: - ||Parameter ||Description ||E= xample || - ||pt ||The Point to use as the center of the filter. Specified as a comm= a separated list of doubles. If using the !LatLonType, then it is lat,lon.= ||&pt=3D33.4,29.0 &pt=3D27.3,83.9,10.0,5.5 || - ||d ||The distance from the point to the outer edge of whatever is being = used to filter on (bounding box, pure distance, something else). Must be g= reater than or equal to 0 ||&d=3D10.0 || - ||sphere_radius ||The radius of the sphere to be used when calculating di= stances on a sphere (i.e. haversine). Default is the Earth's mean radius i= n kilometers (see org.apache.lucene.spatial.DistanceUtils.EARTH_MEAN_RADIUS= _KM) which is set to 6371.009. Most applications will not need to set this= . ||&sphere_radius=3D10.3 || - ||meas ||NOTE: This value is experimental and subject to removal. Most a= pplications will not need to change the measure. The !FieldTypes usually m= ake the proper choice given the data stored. The distance measure to use wh= en calculating distance. The default is dependent on the FieldType. Suppo= rted values are: 1. hsin - The haversine 2. 0, 1, 2, ... INF for the approp= riate p-norm (2 is the Euclidean Distance) ||&meas=3Dhsin. || - = - = - = - = - For !LatLonType, the sfilt command calculates a bounding box by calculati= ng the East and West Longitudes and the North and South Latitudes of a box = that transcribes the circle with radius d (using hsin). There are other wa= ys that this can be implemented by overriding the createSpatialQuery method= on !LatLonType. - = - For !PointType, the bounding box is calculated by standard rectangular co= ordinate system measures. - = - =3D=3D Filtering Caveats =3D=3D - =3D=3D=3D North/South Poles =3D=3D=3D - When the bounding box includes a Pole, then the !LatLonType will automati= cally switch from producing a bounding box to a "bounding bowl" (i.e. a sph= erical cap: http://mathworld.wolfram.com/SphericalCap.html) whereby it will= include all values that are North or South of the latitude of the would be= bounding box (the lower left and the upper right) that is closer to the eq= uator. In other words, we still calculate what the coordinates of the uppe= r right corner and the lower left corner of the box would be just as in all= other filtering cases, but we then take the corner that is closest to the = equator (since it goes over the pole it may not be the lower left, despite = the name) and do a latitude only filter. Obviously, this means there will = be more matches than a pure bounding box match, but the query is much easie= r to construct and will likely be faster, too. - = - =3D Sorting =3D - https://issues.apache.org/jira/browse/SOLR-1297 added the ability to sort= by function, so sorting by distance is now simply a matter of sorting usin= g the appropriate distance function, just like boosting. - = - =3D Scoring =3D - Scoring by distance works just like any other FunctionQuery. See the dis= tance methods on the FunctionQuery page for examples and method signatures. - = - =3D Query Parsing =3D - TODO - = - https://issues.apache.org/jira/browse/SOLR-1578 See https://issues.apache= .org/jira/browse/SOLR-1568 - = - =3D Other Caveats =3D - Unless otherwise specified, all units are kilometers. - = - =3D Known Issues =3D - See https://issues.apache.org/jira/browse/SOLR-773 for tracking - = - =3D Useful References =3D - 1. http://www.movable-type.co.uk/scripts/latlong.html - 1. http://www.ibm.com/developerworks/opensource/library/j-spatial/index.= html - 1. http://www.nsshutdown.com/projects/lucene/whitepaper/locallucene_v2.h= tml -=20