Benutzer-Werkzeuge

Webseiten-Werkzeuge


drupal:solr

Solr

Using FreeBSD 10.1 with jetty 8.1 installed using ports and solr 4.10.x.

Install the drupal modules:

cd /usr/local/www/drupal7
drush dl apachesolr apachesolr_autocomplete

Install solr:

cd /usr/ports/textproc/apache-solr
make install clean

Add it to jetty:

cd /usr/local/jetty/webapps
ln -s /usr/local/share/java/classes/solr-4*.war solr.war

Configure jetty:

/etc/rc.conf
jetty_enable=YES
jetty_flags="-DHUDSON_HOME=/usr/local/hudson -Djava.awt.headless=true -Dsolr.solr.home=/usr/local/solr"
/usr/local/jetty/contexts/solr-jetty-context.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath"><SystemProperty name="hostContext" default="/multicore"/></Set>
  <Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr.war</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home"/>/etc/webdefault.xml</Set>
  <Set name="tempDirectory"><Property name="jetty.home" default="."/>/solr-webapp</Set>
</Configure>
/usr/local/solr/solr.xml
<?xml version="1.0" encoding="UTF-8" ?>
 
<solr>
 
  <solrcloud>
 
    <str name="host">${host:}</str>
    <int name="hostPort">${jetty.port:8983}</int>
    <str name="hostContext">${hostContext:solr}</str>
 
    <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
 
    <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
    <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
    <int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
 
  </solrcloud>
 
  <shardHandlerFactory name="shardHandlerFactory"
    class="HttpShardHandlerFactory">
    <int name="socketTimeout">${socketTimeout:600000}</int>
    <int name="connTimeout">${connTimeout:60000}</int>
  </shardHandlerFactory>
 
</solr>
/usr/local/solr/multicore/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5

We have on our drupal site already the apachesolr module installed, so we copy now the configuration file:

mkdir -p /usr/local/solr/drupal
cd !$
cp -R /usr/local/www/drupal7/sites/all/modules/apachesolr/solr-conf/solr-4.x conf

We have to apply to following diff to get it working with solr-4.10:

--- schema.xml.orig     2015-05-30 14:14:08.554095099 +0200
+++ schema.xml  2015-05-30 13:59:26.130154768 +0200
@@ -96,7 +96,7 @@
      and require different update frequencies than the documents they are
      associated with.
     -->
-    <fieldType name="pfloat" class="solr.FloatField" omitNorms="true"/>
+    <fieldType name="pfloat" class="solr.TrieFloatField" omitNorms="true"/>
     <fieldType name="file" keyField="id" defVal="1" stored="false" indexed="false" class="solr.ExternalFileField" valType="pfloat"/>
 
     <!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and
@@ -119,7 +119,7 @@
 
          Consult the DateField javadocs for more information.
       -->
-    <fieldType name="date" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>
+    <fieldType name="date" class="solr.TrieDateField" sortMissingLast="true" omitNorms="true"/>
 
     <!-- A Trie based date field for faster date range queries and date faceting. -->
     <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

Create file that solr finds the configuration:

/usr/local/solr/drupal/core.properties
name=drupal

Fix permissions:

cd /usr/local/solr
chown -R www *
chgrp -R www *

Restart jetty:

service jetty restart

Access the site http://hostname:8080/multicore/ to test it. You should see now a dashboard and you can configure the core.

Now access your drupal site and enter the apachesolr configuration. Put in solr server URL: http://localhost:8080/multicore/drupal. If you click on Test connection you should get an ok.

You have now only to index everything and you have solr with drupal up and running.

Secure your jetty installation by make it only available from localhost. To do this edit:

/usr/local/jetty/etc/jetty.xml
    <Call name="addConnector">
      <Arg>
          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <Set name="host"><Property name="jetty.host" default="localhost"/></Set>
            <Set name="port"><Property name="jetty.port" default="8080"/></Set>

and restart jetty:

service jetty restart
drupal/solr.txt · Zuletzt geändert: 2015/05/31 12:49 von idefix