lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "SpatialSearch" by YonikSeeley
Date Thu, 30 Sep 2010 21:34:51 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "SpatialSearch" page has been changed by YonikSeeley.
The comment on this change is: doc geodist, manual bounding box via range query.
http://wiki.apache.org/solr/SpatialSearch?action=diff&rev1=34&rev2=35

--------------------------------------------------

  '''NOTE: Unless otherwise specified, all units of distance are kilometers and points are
in degrees of latitude,longitude.'''
  
  = QuickStart =
- If you haven't already, get a recent nightly build of [[Solr4.0]], start the example server
and index the example data as shown in the [[http://lucene.apache.org/solr/tutorial.html|solr
tutorial]].
+ If you haven't already, get a recent nightly build of [[Solr4.0]], start the example server
and index the example data as shown in the [[http://lucene.apache.org/solr/tutorial.html|solr
tutorial]].  With the Solr server running, you should be able to
+ click on the example links and see real responses.
  
  In the example data, certain documents have a field called "store" (with a fieldType named
"location" implemented via !LatLonType).  Some of the points in the example data are:
  {{{
@@ -27, +28 @@

  == geofilt - The distance filter ==
  Now let's assume that we are at '''45.15,-93.85''' (which happens to be 3.437 km from the
Buffalo store).  We can use a '''geofilt''' filter to find all products (documents in our
index) with the field '''store''' within '''5km''' of our position:
  
- [[http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&fq={!geofilt%20pt=45.15,-93.85%20sfield=store%20d=5|...&q=*:*&fq={!geofilt
pt=45.15,-93.85 sfield=store d=5}]]
+    [[http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&fq={!geofilt%20pt=45.15,-93.85%20sfield=store%20d=5|...&q=*:*&fq={!geofilt
pt=45.15,-93.85 sfield=store d=5}]]
  
  Sure enough, we find 8 products at the Buffalo store:
  {{{
@@ -58, +59 @@

  
  Because the bounding box is less selective, if we change our distance to 3km it will still
include the Buffalo store (which is actually 3.437 km away).  If we used the more accurate
'''geofilt''' at 3km, these documents not match.  There are many scenarios when the bounding
box can make sense though - especially if you are sorting by some other criteria anyway, or
sorting by distance itself.
  
+ Since the !LatLonType field also supports field queries and range queries, so one can manually
create their own bounding box rather than using bbox:
+    [[http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&fq=store:[45,-94%20TO%2046,-93]|...&q=*:*&fq=store:[45,-94
TO 46,-93] ]]
  
+ == geodist - the distance function ==
+ 
+ '''geodist''' is a function query that yields the calculated distance.  This gives the flexibility
to do a number of interesting things, such as sorting by the distance (Solr can sort by any
function query), or combining the distance with the relevancy score, such as boosting by the
inverse of the distance.
+ 
+ Here's an example of sorting by distance:
+ 
+    [[http://localhost:8983/solr/select?wt=json&indent=true&fl=name,store&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist%28%29%20asc|...&q=*:*&sfield=store&pt=45.15,-93.85&sort=geodist()
asc]]
  
  
  = EDITING IN PROGRESS - ANYTHING BELOW THIS LINE MAY NOT BE ACCURATE =

Mime
View raw message