SlideShare a Scribd company logo
Geospatial search with
       SOLR
       Nicolas Leroy
Geospatial search with SOLR
Geospatial search with
      SOLR
Who am I?
Nicolas Leroy - AUSY/Dataflow
Twitter: nicolasleroy
Drupal.org: http://drupal.org/user/3527
SOLR
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
SOLR
More information:



http://lucene.apache.org/solr/
SOLR
Single core vs Multicore
One index vs Multiple indexes
Multicore
Multicore
Startup script:
cd /Applications/apache-solr-3.5.0/server
java -Dsolr.solr.home=multicore -jar start.jar
Geospatial search
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.
Latitude and longitude
Latitude and longitude
Latitude = horizontal lines
Longitude = vertical lines
World map
Geolocation
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
Drupal + SOLR
Drupal + SOLR: modules
•  search_api + search_api_solr
•  apachesolr
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.
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
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/
Geospatial search with SOLR
Our Story
•  Drupal site
•  Using SOLR with apachesolr module
•  Location module
Problem:
Location information wasn't indexed
Drupal: Location module
The Location module allows real-world
geographic locations to be associated with
Drupal nodes.

http://drupal.org/project/location
Location in action
http://drupal7.local:8080/node/1/edit
Why not indexed?
SOLR doesn't know what to do with this custom
field.
And this field contains multiple values (street,
city, province, country,...)
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.
Schema?
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.
Schema.xml?
<!-- A specialized field for geospatial search. If
indexed, this fieldType must not be multivalued.
-->
<fieldType name="location"
class="solr.LatLonType"
subFieldSuffix="_coordinate"/>
Schema.xml
This field is now included in schema.xml that
comes with apachesolr module.
Code
Index location information
hook_apachesolr_update_index(&$document,
$node) = DEPRECATED

Now use:
hook_index_document_build_ENTITYTYPE
Create new facets
hook_facetapi_facet_info($searcher_info)
apachesolr_location module
http://drupal.org/project/apachesolr_location
Map fields
Indexing callback
Create facets
Doing the geospatial search
Adding a part to the querystring when
searching:
&spatial=[lat]_[long]_[radius]



hook_apachesolr_query_alter($query)
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}
Too hacky (via url)
Should be done with querytypes.
Small Demo
http://drupal7.local:8080
Future?
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
Geospatial search with SOLR
Feedback & follow-up:
http://drupalcampgent.be/feedback

More Related Content

PPTX
Lucene 4 spatial
PDF
Lucene solr 4 spatial extended deep dive
PDF
Lucene/Solr Spatial in 2015: Presented by David Smiley
PPTX
2016-01 Lucene Solr spatial in 2015, NYC Meetup
PPTX
Lucene/Solr spatial in 2015
PDF
Search with Polygons: Another Approach to Solr Geospatial Search
PDF
Sparksummitny2016
PPTX
Apache con big data 2015 magellan
Lucene 4 spatial
Lucene solr 4 spatial extended deep dive
Lucene/Solr Spatial in 2015: Presented by David Smiley
2016-01 Lucene Solr spatial in 2015, NYC Meetup
Lucene/Solr spatial in 2015
Search with Polygons: Another Approach to Solr Geospatial Search
Sparksummitny2016
Apache con big data 2015 magellan

Viewers also liked (6)

PDF
OpenStreetMap Geocoder Based on Solr
PDF
Geospatial Search With Amazon CloudSearch
PPTX
I See NoSQL Document Stores in Geospatial Applications
PDF
Practical Elasticsearch - real world use cases
PDF
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
PDF
LuceneRDD for (Geospatial) Search and Entity Linkage
OpenStreetMap Geocoder Based on Solr
Geospatial Search With Amazon CloudSearch
I See NoSQL Document Stores in Geospatial Applications
Practical Elasticsearch - real world use cases
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
LuceneRDD for (Geospatial) Search and Entity Linkage
Ad

Similar to Geospatial search with SOLR (11)

PPTX
Apache solr
PPTX
DrupalTour. Lviv — Apache solr. Advanced use cases (Artem Sylchuk, InternetDe...
KEY
Intro to Apache Solr for Drupal
PDF
Proximity search with Search API and Leaflet
PPTX
Drupal7 and Apache Solr
PPTX
Apachesolr presentation
PPTX
Rapid Solr Schema Development (Phone directory)
PDF
Geodaten & Drupal 7
PDF
Create a Layar with Drupal
PDF
Mapping in Drupal 7 using OpenLayers
Apache solr
DrupalTour. Lviv — Apache solr. Advanced use cases (Artem Sylchuk, InternetDe...
Intro to Apache Solr for Drupal
Proximity search with Search API and Leaflet
Drupal7 and Apache Solr
Apachesolr presentation
Rapid Solr Schema Development (Phone directory)
Geodaten & Drupal 7
Create a Layar with Drupal
Mapping in Drupal 7 using OpenLayers
Ad

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation_ Review paper, used for researhc scholars
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
MIND Revenue Release Quarter 2 2025 Press Release
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
NewMind AI Weekly Chronicles - August'25 Week I
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
Spectral efficient network and resource selection model in 5G networks
Encapsulation_ Review paper, used for researhc scholars
The AUB Centre for AI in Media Proposal.docx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
sap open course for s4hana steps from ECC to s4
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Understanding_Digital_Forensics_Presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Empathic Computing: Creating Shared Understanding

Geospatial search with SOLR