Expert Level

LocalSolr is a port of the LocalLucene library to the Solr search server. LocalSolr offers geographical searching capabilities to your search engine.
To customize local solr you simple need to alter a few configuration files.


<!-- Configure Indexer Updated for 1.3 release and 1.4 trunk-->
<processor class="com.pjaol.search.solr.update.LocalUpdateProcessorFactory">
<str name="latField">lat</str> <!-- The field used to store your latitude -->
<str name="lngField">lng</str> <!-- The field used to store your longitude -->
<int name="startTier">9</int> <!-- The lowest level to store data at, level 9 covers about 100 miles, level 5 about 1000 -->
<int name="endTier">15</int> <!-- The highest granular level you want to search at, 15 is about 1 mile -->

<processor class="solr.RunUpdateProcessorFactory" />
<processor class="solr.LogUpdateProcessorFactory" />

<!-- configure the localsolr search component -->
<searchComponent name="localsolr" class="com.pjaol.search.solr.component.LocalSolrQueryComponent" >
<str name="latField">lat
</str><!-- The field used to store your latitude -->
<str name="lngField">lng
</str><!-- The field used to store your longitude -->

<!-- localsolr request handler -->
<requestHandler name="geo"
<arr name="components">

Edit solr/conf/schema.xml

<!-- local lucene field types -->
<field name="lat" type="sdouble" indexed="true" stored="true"/><!-- must match the latField in solrconfig.xml -->
<field name="lng" type="sdouble" indexed="true" stored="true"/><!-- must match the lngField in solrconfig.xml -->
<field name="geo_distance" type="sdouble"/> <!-- Optional but used for distributed searching -->
<dynamicField name="_local*" type="sdouble" indexed="true" stored="true"/><!-- used internally by localsolr -->

The _local* fields can be turned to stored="false" if you don't want

these generated fields to be displayed. They are used internally by localsolr to find areas quickly.

Other wise you could potentially use them to find density of results in an area.

Making a request to localsolr


  • qt query template configured in the solrconfig.xml in this example it's 'geo'
  • lat latitude in degrees
  • long longitude in degrees
  • q solr query
  • radius in miles.