You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2011/04/06 17:48:38 UTC

[Solr Wiki] Trivial Update of "SpatialSearch" by SimonRosenthal

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 SimonRosenthal.
The comment on this change is: spelling correction.
http://wiki.apache.org/solr/SpatialSearch?action=diff&rev1=61&rev2=62

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

  Returning distances (and any arbitrary function query value) is currently under development. As a temporary workaround, it's possible to obtain distances by using geodist or geofilt as the only scoring part of the main query.
  
  = Other Use Cases =
- 
  == How to combine with a sub-query to expand results ==
  It is possible to filter by other criteria with an OR clause. Here is an example that says return by Jacksonville, FL or within 50 km from 45.15,-93.85:
  
@@ -96, +95 @@

  == How to facet by distance ==
  Faceting by distance can be done using the frange QParser.  Unfortunately, right now, it is a bit inefficient, but it likely will be fine in most situations:
  
-  . [[http://localhost:8983/solr/select?&q=*:*&sfield=store&pt=45.15,-93.85&facet.query={!frange%20l=0%20u=5}geodist%28%29&facet.query={!frange%20l=5.001%20u=3000}geodist%28%29&wt=xml&facet=true|&q=*:*&sfield=store&pt=45.15,-93.85&facet.query={!frange l=0 u=5}geodist()&facet.query={!frange l=5.001 u=3000}geodist()]]
+  . [[http://localhost:8983/solr/select?&q=*:*&sfield=store&pt=45.15,-93.85&facet.query={!frange%20l=0%20u=5}geodist()&facet.query={!frange%20l=5.001%20u=3000}geodist()&wt=xml&facet=true|&q=*:*&sfield=store&pt=45.15,-93.85&facet.query={!frange l=0 u=5}geodist()&facet.query={!frange l=5.001 u=3000}geodist()]]
  
  == How to boost closest results (with dismax) ==
  It is possible also boost the query by closest results by combining bf with geodist():
  
   . [[http://localhost:8983/solr/select?fl=name,store,score&defType=dismax&q.alt=*:*&fq={!geofilt}&sfield=store&pt=45.15,-93.85&d=50&bf=recip(geodist(),2,200,20)&sort=score%20desc|...&defType=dismax&q.alt=*:*&fq={!geofilt}&sfield=store&pt=45.15,-93.85&d=50&bf=recip(geodist(),2,200,20)&sort=score desc]]
  
- 
- 
  = Advanced Spatial Search =
  Solr also supports other spatial capabilities beyond just latitude and longitude. For example, a !PointType can be used to represent a point in an n-dimensional space. This can be useful, for instance, for searching in CAD drawings or blueprints. Solr also supports other distance measures. See the FunctionQuery page for more information and look for hsin, ghhsin and others.
  
  == LatLonType ==
+ The !LatLonType is the current default spatial field.  Values for this type are of the form {{{latitude,longitude}}}, although the scenes, the lattitude and longitude are indexed as separate numbers. Fields using !LatLonType must be single valued (i.e. multiValued="false").  This field type does distance calculations based on Great Circle (haversine).
- 
- The !LatLonType is the current default spatial field.  Values for this type are of the form {{{lattitude,longitude}}},
- although the scenes, the lattitude and longitude are indexed as separate numbers.
- Fields using !LatLonType must be single valued (i.e. multiValued="false").  This field type does distance calculations based on Great Circle (haversine).
  
  In addition to {{{geofilt}}}, {{{geodist}}} and {{{bbox}}}, the !LatLonType supports field queries such as {{{field:10,20}}} and range queries such as {{{field:[10,20 TO 30,40]}}}.
  
@@ -120, +114 @@

  For the {{{bbox}}} filter, when the bounding box includes a pole, the !LatLonType will switch from producing a bounding box to a "bounding bowl" (i.e. a [[http://mathworld.wolfram.com/SphericalCap.html|spherical cap]]) 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 equator.  In other words, we still  calculate what the coordinates of the upper 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 easier to  construct and will likely be faster, too.
  
  = Spatial Options Under Development =
- SpatialSearchDev -- Covers things like Geohash (supports multivalue lat-lon points), other distance functions, etc. 
+ SpatialSearchDev -- Covers things like Geohash (supports multivalue lat-lon points), other distance functions, etc.