Monday, December 14, 2009

Installing LocalSolr onto Solr 1.4 Server (Step by Step)

Introduction


I created this guide, so you don't have to go through the 2 days of hell I had to go through. Mainly trawling countless websites that all seemed to contradict them selves.. However this is how i managed to get LocalSolr working on my Solr Server. Enjoy

Prerequisites


Before you start using LocalSolr, you'll need to install solr. You can following my guide on installing Solr 1.4 on windows here

Steps


  • Download LocalSolr from here
I took a backup of the solr-example.tgz when i wrote this blog in case they remove the link or update the files inside
  • Extract to a temporary folder
  • Next you'll have to update your solrconfig.xml file
  • Add the following code to your solrconfig.xml file

<updateRequestProcessorChain>
      <processor class="com.pjaol.search.solr.update.LocalUpdateProcessorFactory">
        <str name="latField">lat</str>
        <str name="lngField">lng</str>
  <int name="startTier">4</int>
        <int name="endTier">25</int>
    </processor>
   <processor class="solr.RunUpdateProcessorFactory" />    
   <processor class="solr.LogUpdateProcessorFactory" /> 
  </updateRequestProcessorChain>

<searchComponent name="localsolr" class="com.pjaol.search.solr.component.LocalSolrQueryComponent" />

<requestHandler name="geo" class="org.apache.solr.handler.component.SearchHandler">
 <!-- default values for query parameters -->
     <lst name="defaults">
       <str name="echoParams">explicit</str>
       <!--
       <int name="rows">10</int>
       <str name="fl">*</str>
       <str name="version">2.1</str>
        -->
     </lst>
    <arr name="components">
      <str>localsolr</str>
      <str>facet</str>
      <str>mlt</str>
      <str>highlight</str>
      <str>debug</str>
    </arr>
  </requestHandler>

Here you can see where I added the lines to the existing file (Click image to see large version).


  • Next you'll have to update your schema
  • Add the following code to your schema.xml file

<field name="lat" type="tdouble" indexed="true" stored="true"/>
<field name="lng" type="tdouble" indexed="true" stored="true"/>
<field name="geo_distance" type="tdouble"/>
<dynamicfield name="_local*" type="tdouble" indexed="true" stored="true"/>

  • Stop Apache TomCat Service
  • Delete contents of the Data Folder
solr\Data
  • Copy 2 files from the extract folder
solr-example\apache-solr-1.4.0\example\solr\lib\localsolr.jar
solr-example\apache-solr-1.4.0\example\solr\lib\lucene-spatial-2.9.1.jar
  • to your solr\lib folder
  • Start Apache TomCat Service
  • Perform a solr Geo Search
http://127.0.0.1:8080/solr/select?&qt=geo&q=Day&long=0.104801&qt=geo&lat=52.2439&radius=250

  • Check normal searches still work
http://127.0.0.1:8080/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on

  • Try adding some data to Solr and Re-doing both searches
  • Remember that the geo search also requires a text query. So make sure you include text that's indexed.
http://127.0.0.1:8080/solr/select?&qt=geo&q=Day&long=0.104801&qt=geo&lat=52.2439&radius=250

I used the following reference sites when creating this guide:

9 comments:

  1. References can be found:

    http://issues.apache.org/jira/browse/SOLR-773
    http://www.gissearch.com/localsolr

    ReplyDelete
  2. i did a fresh 1.4 install and tested it, worked fine. then changed config and schema as above but now get:

    "java.lang.NoClassDefFoundError: org/apache/solr/handler/component/SearchComponent"

    i am on linux, not windows. if anyone has any ideas that'd be great.

    ReplyDelete
  3. Thanks for the post, could you comment on the reason to use triedouble vs sortabledouble fields for the lat and lng?

    thanks,
    david

    ReplyDelete
  4. i was thinking about creating a blog too and your post has helped me where to look. i just hope it gets closer to as good as yours then i am all set

    ReplyDelete
  5. Thanks for the post, could you comment on the reason to use triedouble vs sortabledouble fields for the lat and lng?
    Eyelash extensions las vegas

    ReplyDelete
  6. Very nice article to know more about the Karatbars go the website

    ReplyDelete
  7. https://cyberflixtv.xyz was propelled in 2018 and has a very decent reach to the individuals. Time by time it is being famous among the clients around the world. There are numerous explanations behind this.

    ReplyDelete
  8. i just hope it gets closer to as good as yours then i am all set
    krnl.fun
    hdstreamz apk

    ReplyDelete