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:

12 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. Thankyou so much for this detailed information, keep up the good work. Here is the link of my website Kerala Homes Plan

    ReplyDelete
  6. 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
  7. Very nice article to know more about the Karatbars go the website

    ReplyDelete
  8. 8 Ball Pool is an easygoing computer game on iOS and Android cell phones, created by Miniclip.com and discharged in 2010. As one of the most well known games on the planet, 8 Ball Pool steadfastly return the game on cell phone for fans.

    ReplyDelete
  9. 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
  10. Crypto-currency as a modern form of the digital asset has received a worldwide acclaim for easy and faster financial transactions and its awareness among people have allowed them to take more interest in the field thus opening up new and advanced ways of making payments. Crypto.com Referral Code with the growing demand of this global phenomenon more,new traders and business owners are now willing to invest in this currency platform despite its fluctuating prices however it is quite difficult to choose the best one when the market is full. In the list of crypto-currencies bit-coins is one of the oldest and more popular Crypto.com Referral Code for the last few years. It is basically used for trading goods and services and has become the part of the so-called computerized block-chain system allowing anyone to use it thus increasing the craze among the public, Crypto.com Referral Code.

    Common people who are willing to purchase BTC can use an online wallet system for buying them safely in exchange of cash or credit cards and in a comfortable way from the thousands of BTC foundations around the world and keep them as assets for the future. Due to its popularity, many corporate investors are now accepting them as cross-border payments and the rise is unstoppable. With the advent of the internet and mobile devices,information gathering has become quite easy as a result the BTC financial transactions are accessible and its price is set in accordance with people’s choice and preferences thus leading to a profitable investment with Crypto.com Referral Code. Recent surveys have also proved that instability is good for BTC exchange as if there is instability and political unrest in the country due to which banks suffer then investing in BTC can surely be a better option. Again bit-coin transaction fees are pretty cheaper and a more convenient technology for making contracts thus attracting the crowd. The BTC can also be converted into different fiat currencies and is used for trading of securities, for land titles, document stamping, public rewards and vice versa.

    Another advanced block-chain project is Ethereumor the ETH which has served much more than just a digital form of crypto-currency Crypto.com Referral Code and its popularity in the last few decades have allowed billions of people to hold wallets for them. With the ease of the online world,the ETH have allowed the retailers and business organizations to accept them for trading purposes, therefore, can serve as the future of the financial system.

    ReplyDelete