1 / 13

Implementing Local Search with Apache Solr and Lucene

Implementing Local Search with Apache Solr and Lucene. Grant Ingersoll. Topics. Use Cases Concepts of Local Search Local Search support in Apache Solr Indexing Filtering Searching Faceting Sorting Demo. Use Cases. Asset Management Social Networking Find all friends near me

adler
Download Presentation

Implementing Local Search with Apache Solr and Lucene

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Implementing Local Search with Apache Solr and Lucene Grant Ingersoll

  2. Topics • Use Cases • Concepts of Local Search • Local Search support in Apache Solr • Indexing • Filtering • Searching • Faceting • Sorting • Demo

  3. Use Cases • Asset Management • Social Networking • Find all friends near me • Targeted, local search results and ads • “restaurants in Austin Texas” • “Starbucks, 55313” • Business Intelligence • Restrict doc set for analysis by location

  4. Spatial Search Concepts • Spatial Data Types • Points (latitude/longitude) • Lines • Shapes • Maps and overlays • Streets, POI • Integration with unstructured text • Metadata, descriptions, user reviews, etc. http://www.openstreetmap.org/?lat=44.9744&lon=-93.2484&zoom=14&layers=B000FTFT

  5. Application Needs • Query Parsing • Efficient distance calculations • Euclidean, Great Circle (Haversine), Vincenty’s • Filtering • Bounding Box • Sort by Distance • Relevance Enhancement • Faceting • Advanced: shape intersections, routes

  6. State of Solr Spatial • Native Field Types for Latitude/Longitude as well as n-dimensional Point • Native support for: • Filtering by distance • Boosting by distance • Sorting by distance • Faceting by distance (sort of) • Still needed: • Pseudo Fields • Query Parser support for geocoding • Shapes

  7. Configuration • Schema • <fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/> • <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/> • <fieldtype name="geohash" class="solr.GeoHashField"/> • Solrconfig: • None!

  8. Indexing • Just like always: <doc> <field name="id">6H500F0</field> <field name="name">Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300</field> … <field name="store">45.17614,-93.87341</field> </doc>

  9. Distance Functions • Most spatial operations (sorting, boosting, filtering, faceting) stem from the use of Solr’s built-in Function Query capability • http://wiki.apache.org/solr/FunctionQuery • dist(Power, pointA, pointB) – n-dimensional distance calculation • sqedist(pointA, pointB) – Squared Euclidean • hsin, ghhsin – Haversine (great circle) distance • geodist – Hides the details of other distance measures • Most people should just use geodist(), but others may want more control

  10. Filtering • Accuracy matters! • geofilt – Radius based filter • &q=*:*&fq={!geofilt pt=45.15,-93.85 sfield=store d=5} • ...&q=*:*&fq={!geofilt sfield=store}&pt=45.15,-93.85&d=5 • bbox – Bounding Box (less accurate) • &q=*:*&fq={!bbox}&sfield=store&pt=45.15,-93.85&d=5

  11. Boosting and Sorting • Increase the score of a document based on the distance: • &q={!func}geodist()&sfield=store&pt=45.15,-93.85&sort=score asc • Sort based on Distance • &q=*:*&fq={!geofilt}&sfield=store&pt=45.15,-93.85&d=50&sort=geodist() asc

  12. Faceting • Use the FRange Functionality • Not ideal, but works • http://localhost:8983/solr/select?&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()&facet=true

  13. Resources • http://wiki.apache.org/solr/SpatialSearch • http://www.lucidimagination.com/search/?q=spatial • https://www.ibm.com/developerworks/java/library/j-spatial/ • Outdated, but covers the concepts • @gsingers • grant@lucidimagination.com

More Related