Skip to content

Install Solr and GSearch

Adam edited this page Mar 12, 2018 · 6 revisions

Contents:

Common Properties

Variables Typical Value Description
$FEDORA_HOME /usr/local/fedora The directory into which Fedora has been installed.
$CATALINA_HOME $FEDORA_HOME/tomcat Location of the Tomcat installation. Typical value assumes that the Fedora-provided Tomcat is being used, or an equivalent environment has been setup.

NOTE: We assume the use of a single instance of Tomcat in this documentation. If multiple are being served, it may be necessary to substitute $CATALINA_BASE instead of $CATALINA_HOME in most cases.

Install Solr

  1. Stop Fedora.

  2. Download the desired version of Solr to /opt:

    basic-solr-config Branch Solr Versions
    modular 3.6.2 (down to 1.4 may work)
    4.x 4.2.0
    4.10.x 4.10.4
  3. Unpack the download archive.

  4. Clone/unpack the matching branch of the basic-solr-config. In this documentation, we'll say we cloned it to /opt/gsearch_config:

    # $BRANCH should correspond to the `basic-solr-config` branch for the given version of Solr.
    git clone [email protected]:discoverygarden/basic-solr-config.git --recursive --branch=$BRANCH /opt/gsearch_config
  5. Make a symbolic link to the solr directory such that /opt/solr points at the unpacked archive.

    ln -s /opt/solr-4.2.0 /opt/solr
  6. Add the following XML file to $CATALINA_HOME/conf/Catalina/localhost/solr.xml. The /Context/@docBase attribute should be altered to point at the .war unpacked from the archive above, in the /opt/solr/dist directory.

    <?xml version="1.0" encoding="UTF-8"?>
    <Context docBase="/opt/solr/dist/solr-4.2.0.war" debug="0" crossContext="true">
      <Environment name="solr/home" type="java.lang.String" value="/usr/local/fedora/solr" override="true"/>
    </Context>
  7. Copy over the default configuration files. This should be something like:

    cp -r /opt/solr/example/solr $FEDORA_HOME/solr

Configure Solr

Overwrite the example Solr config with that provided in our branch. Before Solr 4, this was something like $FEDORA_HOME/solr/conf. For 4 and later, it should be something like $FEDORA_HOME/solr/collection1/conf:

cp -r /opt/gsearch_config/conf $FEDORA_HOME/solr/collection1/conf

Potential Solr config issues

Error loading class solr.EnglishPorterFilterFactory

collection1: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "text": Plugin init failure for [schema.xml] analyzer/filter: Error loading class 'solr.EnglishPorterFilterFactory'

Change the deprecated EnglishPorterFilterFactory to use SnowballPorterFilterFactory, such that:

<filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>

becomes:

<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>

Unable to use updateLog: _version_field

collection1: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Unable to use updateLog: _version_field must exist in schema, using indexed="true" stored="true" and multiValued="false" (_version_ is multiValued

Changed the version of the schema from 1.1 to version 1.5 which includes these changes:

       1.2: omitTermFreqAndPositions attribute introduced, true by default
            except for text fields.
       1.3: removed optional field compress feature
       1.4: autoGeneratePhraseQueries attribute introduced to drive QueryParser
            behavior when a single string produces multiple tokens.  Defaults
            to off for version >= 1.4
       1.5: omitNorms defaults to true for primitive field types
            (int, float, boolean, string…)

Also Added the following field to the schema.

<field name="_version_" type="long" indexed="true" stored="true"/> 

Install GSearch

With Fedora still stopped:

  1. Place the fedoragsearch.war file in $FEDORA_HOME/tomcat/webapps

  2. Unzip the placed .war file:

    unzip $CATALINA_HOME/webapps/fedoragsearch.war -d $CATALINA_HOME/webapps/fedoragsearch
  3. Navigate to $CATALINA_HOME/webapps/fedoragsearch/FgsConfig

    cd $CATALINA_HOME/webapps/fedoragsearch/FgsConfig
  4. Modify the fgsconfig-basic.properties file as needed be sure that the following properties are set correctly: <path to fedora home> should be the absolute path to your $FEDORA_HOME directory:

    configDisplayName=configDemoOnSolr
    local.FEDORA_HOME=<path to fedora home> 
    indexEngine=Solr
    indexDir=${local.FEDORA_HOME}/solr/collection1/data/index
    indexBase=http://localhost:8080/solr 
    indexingDocXslt=foxmlToSolr    

    NOTE: The indexDir directory location varies. Prior to Solr 4, it would have been something like: ${local.FEDORA_HOME}/solr/data/index

  5. Run the following commands to generate the basic configuration:

    ant generateIndexingXslt
    ant -f fgsconfig-basic.xml
  6. Install the DGI GSearch Extensions to GSearch. See its included directions for details.

  7. Go to the index directory of the GSearch:

    cd  $CATALINA_HOME/webapps/fedoragsearch/WEB-INF/classes/fgsconfigFinal/index/FgsIndex
  8. Overwrite $CATALINA_HOME/webapps/fedoragsearch/WEB-INF/classes/fgsconfigFinal/index/FgsIndex/foxmlToSolr.xslt with /opt/gsearch_config/foxmlToSolr.xslt:

    cp /opt/gsearch/foxmlToSolr.xslt $CATALINA_HOME/webapps/fedoragsearch/WEB-INF/classes/fgsconfigFinal/index/FgsIndex/foxmlToSolr.xslt

    NOTE: If you keep Fedora or Tomcat in the non-default location, you will need to update the paths of referenced/included *.xslt files to reflect the target location.

  9. Copy /opt/gsearch_config/islandora_transforms to $CATALINA_HOME/webapps/fedoragsearch/WEB-INF/classes/fgsconfigFinal/index/FgsIndex:

    cp -r /opt/gsearch_config/islandora_transforms $CATALINA_HOME/webapps/fedoragsearch/WEB-INF/classes/fgsconfigFinal/index/FgsIndex

    NOTE: If you keep Fedora or Tomcat in the non-default location, you will need to update each of the *.xslt files to reflect the target location.

  10. Start Fedora

FAQ

Couldn't Access http://<sitename>:8080/fedoragsearch/rest

$CATALINA_HOME/webapps/fedoragsearch/WEB-INF/classes/fgsconfigFinal/index/FgsIndex/foxmlToSolr.xslt was not present and it is the "default" solr xslt now in gsearch 2.7+.

Please read over sort out this issue see Install GSearch

cd $CATALINA_HOME/webapps/fedoragsearch/FgsConfig 
ant generateIndexingXslt
ant -f fgsconfig-basic.xml

When visiting http://<sitename>:8080/fedoragsearch/rest?operation=updateIndex the following error appears.

Thu Oct 03 13:33:09 UTC 2013 IndexReader open error indexName=FgsIndex : ; nested exception is: org.apache.lucene.store.NoSuchDirectoryException: directory '/usr/local/fedora/solr/data/index' does not exist

Check the basic properties file as needed be sure that it points at the correct index directory:

indexDir=${local.FEDORA_HOME}/solr/collection1/data/index