Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Geospatial search with SOLR

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
Lucene 4 spatial
Lucene 4 spatial
Cargando en…3
×

Eche un vistazo a continuación

1 de 47 Anuncio

Más Contenido Relacionado

Similares a Geospatial search with SOLR (20)

Anuncio

Más reciente (20)

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/Dataflow Twitter: nicolasleroy Drupal.org: http://drupal.org/user/3527
  4. 4. SOLR
  5. 5. SOLR Solr is the popular, blazing fast open source enterprise search platform from the Apache Lucene project. Its major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering, database integration, rich document handling, and geospatial search. Solr is written in Java
  6. 6. SOLR More information: http://lucene.apache.org/solr/
  7. 7. SOLR Single core vs Multicore One index vs Multiple indexes
  8. 8. Multicore
  9. 9. Multicore Startup script: cd /Applications/apache-solr-3.5.0/server java -Dsolr.solr.home=multicore -jar start.jar
  10. 10. Geospatial search
  11. 11. Geospatial search: definition wikipedia: Geomatics (also known as geospatial technology or geomatics engineering) is the discipline of gathering, storing, processing, and delivering geographic information, or spatially referenced information.
  12. 12. Latitude and longitude
  13. 13. Latitude and longitude Latitude = horizontal lines Longitude = vertical lines
  14. 14. World map
  15. 15. Geolocation
  16. 16. Geolocation: ground mark Surveyor-General Victoria (SGV) is responsible for Victoria’s Geodetic Survey Control Network. This is the infrastructure used to provide accurate position and height referencing across Victoria. It is made up of 140,000 ground marks http://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 + SOLR Drupal: http://drupal.org/start Apachesolr module http://drupal.org/project/apachesolr Download SOLR: http://www.apache.org/dyn/closer.cgi/lucene/ solr/3.6.0
  21. 21. Drupal + SOLR Nice tutorial: http://www.nickveenhof.be/blog/simple-guide- install-apache-solr-3x-drupal-7 Check his blog for screencasts: http://www.nickveenhof.be/
  22. 22. Our Story •  Drupal site •  Using SOLR with apachesolr module •  Location module Problem: Location information wasn't indexed
  23. 23. Drupal: Location module The Location module allows real-world geographic locations to be associated with Drupal nodes. http://drupal.org/project/location
  24. 24. Location in action http://drupal7.local:8080/node/1/edit
  25. 25. Why not indexed? SOLR doesn't know what to do with this custom field. And this field contains multiple values (street, city, province, country,...)
  26. 26. Solution We 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 details about which fields your documents can contain, and how those fields should be dealt with when adding documents to the index, or when querying those fields. Schema.xml comes with the apachesolr module and is configured to handle drupal content.
  29. 29. Schema.xml? <!-- A specialized field for geospatial search. If indexed, this fieldType must not be multivalued. --> <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
  30. 30. Schema.xml This field is now included in schema.xml that comes with apachesolr module.
  31. 31. Code
  32. 32. Index location information hook_apachesolr_update_index(&$document, $node) = DEPRECATED Now use: hook_index_document_build_ENTITYTYPE
  33. 33. Create new facets hook_facetapi_facet_info($searcher_info)
  34. 34. apachesolr_location module http://drupal.org/project/apachesolr_location
  35. 35. Map fields
  36. 36. Indexing callback
  37. 37. Create facets
  38. 38. Doing the geospatial search Adding a part to the querystring when searching: &spatial=[lat]_[long]_[radius] hook_apachesolr_query_alter($query)
  39. 39. hook_apachesolr_query_alter $query->addParam('fq', "{!geofilt sfield=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 Demo http://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

×