11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ox<br />

The bbox filter is very similar to geofilt except it uses the bounding box of the calculated circle. See the blue<br />

box in the diagram below. It takes the same parameters as geofilt. Here's a sample query: &q=*:*&fq={!bbox<br />

sfield=store}&pt=45.15,-93.85&d=5. The rectangular shape is faster to compute and so it's sometimes<br />

used as an alternative to geofilt when it's acceptable to return points outside of the radius. However, if the ideal<br />

goal is a circle but you want it to run faster, then instead consider using the RPT field and try a large "distErrPct"<br />

value like 0.1 (10% radius). This will return results outside the radius but it will do so somewhat uniformly around<br />

the shape.<br />

When a bounding box includes a pole, the bounding box ends up being a "bounding bowl" (a spherical<br />

cap) that includes all values north of the lowest latitude of the circle if it touches the north pole (or south<br />

of the highest latitude if it touches the south pole).<br />

Filtering by an arbitrary rectangle<br />

Sometimes the spatial search requirement calls for finding everything in a rectangular area, such as the area<br />

covered by a map the user is looking at. For this case, geofilt and bbox won't cut it. This is somewhat of a trick,<br />

but you can use <strong>Solr</strong>'s range query syntax for this by supplying the lower-left corner as the start of the range and<br />

the upper-right corner as the end of the range. Here's an example: &q=*:*&fq=store:[45,-94 TO 46,-9<br />

3] . LatLonType does not support rectangles that cross the dateline, but RPT does. If you are using RPT with<br />

non-geospatial coordinates ( geo="false" ) then you must quote the points due to the space, e.g. "x y" .<br />

Optimization: <strong>Solr</strong> Post Filtering<br />

Most likely, the fastest spatial filters will be to simply use the RPT field type. However, sometimes it may be<br />

faster to use LatLonType with <strong>Solr</strong> post filtering in circumstances when both the spatial query isn't worth caching<br />

and there aren't many matching documents that match the non-spatial filters (e.g. keyword queries and other<br />

filters). To use <strong>Solr</strong> post filtering with LatLonType, use the bbox or geofilt query parsers in a filter query but<br />

specify cache=false and cost=100 (or greater) as local-params. Here's a short example:<br />

&q=...mykeywords...&fq=...someotherfilters...&fq={!geofilt cache=false<br />

cost=100}&sfield=store&pt=45.15,-93.85&d=5<br />

Distance Function Queries<br />

There are four distance function queries: geodist, see below, usually the most appropriate; dist, to calculate<br />

the p-norm distance between multi-dimensional vectors; hsin, to calculate the distance between two points on a<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

372

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!