Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
OpenStreetMap Geocoder Based on Solr
Next

12

Share

Geospatial search with SOLR

This was my presentation for Drupalcamp Gent 2012. Presented on Friday May 25, 2012.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Geospatial search with SOLR

  1. 1. Geospatial search with SOLR Nicolas Leroy
  2. 2. Geospatial search with SOLR
  3. 3. Who am I?Nicolas Leroy - AUSY/DataflowTwitter: nicolasleroyDrupal.org: http://drupal.org/user/3527
  4. 4. SOLR
  5. 5. SOLRSolr is the popular, blazing fast open sourceenterprise search platform from the ApacheLucene project.Its major features include powerful full-textsearch, hit highlighting, faceted search,dynamic clustering, database integration, richdocument handling, and geospatial search.Solr is written in Java
  6. 6. SOLRMore information:http://lucene.apache.org/solr/
  7. 7. SOLRSingle core vs MulticoreOne index vs Multiple indexes
  8. 8. Multicore
  9. 9. MulticoreStartup script:cd /Applications/apache-solr-3.5.0/serverjava -Dsolr.solr.home=multicore -jar start.jar
  10. 10. Geospatial search
  11. 11. Geospatial search: definitionwikipedia:Geomatics (also known as geospatialtechnology or geomatics engineering) is thediscipline of gathering, storing, processing, anddelivering geographic information, orspatially referenced information.
  12. 12. Latitude and longitude
  13. 13. Latitude and longitudeLatitude = horizontal linesLongitude = vertical lines
  14. 14. World map
  15. 15. Geolocation
  16. 16. Geolocation: ground markSurveyor-General Victoria (SGV) is responsiblefor Victoria’s Geodetic Survey Control Network.This is the infrastructure used to provideaccurate position and height referencing acrossVictoria. It is made up of 140,000 ground markshttp://www.dse.vic.gov.au/property-titles-and-maps/surveying-home-page/government-survey-services/victorias-survey-infrastructure
  17. 17. Drupal + SOLR
  18. 18. Drupal + SOLR: modules•  search_api + search_api_solr•  apachesolr
  19. 19. Geospatial Options•  geofield + geocoder + search_api + search_api_location•  location + search_api + search_api_location•  location + gmap + apachesolr + apachesolr_location•  apachesolr_geo still a sandbox, not much information.
  20. 20. Drupal + SOLRDrupal:http://drupal.org/startApachesolr modulehttp://drupal.org/project/apachesolrDownload SOLR:http://www.apache.org/dyn/closer.cgi/lucene/ solr/3.6.0
  21. 21. Drupal + SOLRNice tutorial:http://www.nickveenhof.be/blog/simple-guide- install-apache-solr-3x-drupal-7Check his blog for screencasts:http://www.nickveenhof.be/
  22. 22. Our Story•  Drupal site•  Using SOLR with apachesolr module•  Location moduleProblem:Location information wasnt indexed
  23. 23. Drupal: Location moduleThe Location module allows real-worldgeographic locations to be associated withDrupal nodes.http://drupal.org/project/location
  24. 24. Location in actionhttp://drupal7.local:8080/node/1/edit
  25. 25. Why not indexed?SOLR doesnt know what to do with this customfield.And this field contains multiple values (street,city, province, country,...)
  26. 26. SolutionWe wrote some custom code to:•  index location information properly•  generate facets•  provide a search form for geospatial search (longitude, latitude + radius)We changed schema.xml to use a"solr.LatLonType" field.
  27. 27. Schema?
  28. 28. Schema.xml?The schema.xml file contains all of the detailsabout which fields your documents cancontain, and how those fields should be dealtwith when adding documents to the index, orwhen querying those fields.Schema.xml comes with the apachesolrmodule and is configured to handle drupalcontent.
  29. 29. Schema.xml?<!-- A specialized field for geospatial search. Ifindexed, this fieldType must not be multivalued.--><fieldType name="location"class="solr.LatLonType"subFieldSuffix="_coordinate"/>
  30. 30. Schema.xmlThis field is now included in schema.xml thatcomes with apachesolr module.
  31. 31. Code
  32. 32. Index location informationhook_apachesolr_update_index(&$document,$node) = DEPRECATEDNow use:hook_index_document_build_ENTITYTYPE
  33. 33. Create new facetshook_facetapi_facet_info($searcher_info)
  34. 34. apachesolr_location modulehttp://drupal.org/project/apachesolr_location
  35. 35. Map fields
  36. 36. Indexing callback
  37. 37. Create facets
  38. 38. Doing the geospatial searchAdding a part to the querystring whensearching:&spatial=[lat]_[long]_[radius]hook_apachesolr_query_alter($query)
  39. 39. hook_apachesolr_query_alter$query->addParam(fq, "{!geofiltsfield=locs_coordinates" . " pt=" . $keys[0] . , .$keys[1] . " d=" . $distance . "}");{!geofilt sfield=locs_coordinates pt=50.879816,4.706429 d=10}
  40. 40. Too hacky (via url)Should be done with querytypes.
  41. 41. Small Demohttp://drupal7.local:8080
  42. 42. Future?
  43. 43. Future•  Adding city + radius box•  Getting coordinates of the city•  Search for items within that range•  Adding visualisation•  Settings UI: miles or km,…What would you add? Let us know!http://drupal.org/project/apachesolr_location
  44. 44. Feedback & follow-up:http://drupalcampgent.be/feedback
  • fmably

    May. 25, 2016
  • anancds

    Oct. 29, 2015
  • wsh6759

    Sep. 1, 2015
  • vaibhavsanil

    Apr. 20, 2015
  • slam33661490

    Nov. 19, 2014
  • debasys

    Sep. 20, 2014
  • nitinaiduangjan

    Jul. 21, 2014
  • balalaikaboy

    May. 29, 2014
  • janwen

    Aug. 30, 2013
  • GiuseppeMastroeni

    Aug. 3, 2013
  • svilensabev

    Jul. 9, 2013
  • knibals

    Dec. 3, 2012

This was my presentation for Drupalcamp Gent 2012. Presented on Friday May 25, 2012.

Views

Total views

14,262

On Slideshare

0

From embeds

0

Number of embeds

28

Actions

Downloads

0

Shares

0

Comments

0

Likes

12

×