This directory contains a basic test SOLR install with one core configured to track a local Alfresco instance.

The lib directory contents has to built or copied first.
In the root directory (../../../../..) compile and copy the jars using:

ant deploy-solr

You will have to do this each time you update.



Copy 

solr-tomcat-context.xml 

to 

apache-tomcat-6.0.26\conf\Catalina\localhost\solr.xml

Edit the file and set:

1) docBase to the solr war file in this directory (or a copy)
2) solr/home environment to this directory or a copy

For each core:
archive-SpacesStore/conf
workspace-SpacesStore/conf

edit solrcore.properties to define:

 # Follow the pattern <dataDir>/localhost/workspace/SpacesStore
 data.dir.root=w:/solrData/localhost
 alfresco.url=http://localhost:8080/alfresco/service

and possibly how often you want to update

 alfresco.cron=0/15 * * * * ? *

The other defaults should be OK.



SSL Setup (for Tomcat)
~~~~~~~~~~~~~~~~~~~~~~

Repository-Solr communications are protected by SSL with mutual authentication out of the box. Both the repository and Solr have their own private/public RSA key pair,
signed by an Alfresco Certificate Authority.

It is assumed that the keystore files are stored in alf_data. Place the keystore files from the directory repository/config/alfresco/keystore in the $ALF_DATA/keystore directory

There are two configurations that are relevant in terms of configuration:

1) The repository and Solr running in the same Tomcat instance
2) The repository and Solr running in different Tomcat instances

These are documented separately below.

Separate Tomcat Instances Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   Repository Configuration
   ~~~~~~~~~~~~~~~~~~~~~~~~

   Add this to the tomcat-users.xml file where the repository is deployed (this allows Solr to SSL authenticate with the Repository):

      <user username="CN=Alfresco Repository Client, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB" roles="repoclient" password="null"/>

   Configure an SSL connector by adding this to the Tomcat server.xml file where the repo is deployed:
  
      <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
               maxThreads="150" scheme="https" keystoreFile="../../data/keystore/ssl.keystore" keystorePass="kT9X6oe68t" keystoreType="JCEKS"
               secure="true" connectionTimeout="240000" truststoreFile="../../data/keystore/ssl.truststore" truststorePass="kT9X6oe68t" truststoreType="JCEKS"
               clientAuth="false" sslProtocol="TLS" />  

   Add dir.keystore=${dir.root}/keystore to your alfresco-global.properties file.

   Solr Configuration
   ~~~~~~~~~~~~~~~~~~

   Add this to the tomcat-users.xml file where solr is deployed (this allows the Repository to SSL authenticate with Solr):

      <user username="CN=Alfresco Repository, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB" roles="repository" password="null"/>

   Configure an SSL connector by adding this to the Tomcat server.xml file where solr is deployed:
  
      <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
               maxThreads="150" scheme="https" keystoreFile="../../data/keystore/ssl.keystore" keystorePass="kT9X6oe68t" keystoreType="JCEKS"
               secure="true" connectionTimeout="240000" truststoreFile="../../data/keystore/ssl.truststore" truststorePass="kT9X6oe68t" truststoreType="JCEKS"
               clientAuth="false" sslProtocol="TLS" /> 

Single Tomcat Instance Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add these entries to the tomcat-users.xml file where the repository is deployed (this allows Solr to SSL authenticate with the Repository):

  <user username="CN=Alfresco Repository Client, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB" roles="repoclient" password="null"/>
  <user username="CN=Alfresco Repository, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB" roles="repository" password="null"/>
  
Configure an SSL connector by adding this to the Tomcat server.xml file where the repo is deployed:
  
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
               maxThreads="150" scheme="https" keystoreFile="../../data/keystore/ssl.keystore" keystorePass="kT9X6oe68t" keystoreType="JCEKS"
 secure="true" connectionTimeout="240000" truststoreFile="../../data/keystore/ssl.truststore" truststorePass="kT9X6oe68t" truststoreType="JCEKS"
               clientAuth="false" sslProtocol="TLS" />  

Add dir.keystore=${dir.root}/keystore to your alfresco-global.properties file.

               

Ensure that the repository property 'solr.port.ssl' in alfresco-global.properties is set to the Solr Tomcat SSL port (SSL redirects don't work yet).
Ensure that the Solr property 'alfresco.port.ssl' is set to the Repository Tomcat SSL port in the solrcore.properties for _each_ Solr core.

Troubleshooting
~~~~~~~~~~~~~~~

Note: if you get something like this on the Tomcat console (and are finding that Solr search and/or the Solr tracking is not working):

    Aug 22, 2011 8:19:21 PM org.apache.tomcat.util.net.jsse.JSSESupport handShake
    WARNING: SSL server initiated renegotiation is disabled, closing connection

it indicates that one side of the SSL connection is trying to re-negotiate the SSL connection. This form of negotiation was found to 
be susceptible to man-in-the-middle attacks and it was disabled in the Java JSEE stack until a fix could be applied. See here:
http://www.oracle.com/technetwork/java/javase/documentation/tlsreadme2-176330.html. See also:

o http://www.gremwell.com/enabling_ssl_tls_renegotiation_in_java
o http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

If your version of Java does not have the fix (which my Mac version doesn't seem to), you will need to re-enabled re-negotiation by performing the following steps:

(i) Add -Dsun.security.ssl.allowUnsafeRenegotiation=true to JAVA_OPTS
(ii) Add 'allowUnsafeLegacyRenegotiation="true"' to the Tomcat SSL connector

End Solr SSL Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~


Please delete the SOLR data dir everytime you update this distribution directory as it may invalidate the state of the index :-)


See: http://wiki.apache.org/solr/SolrTomcat for more ....


e.g.


<?xml version="1.0" encoding="utf-8"?>
<Context docBase="W:/alfresco/BRANCHES/DEV/SWIFT/root/projects/solr/source/solr/instance/apache-solr-1.4.1.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="W:/alfresco/BRANCHES/DEV/SWIFT/root/projects/solr/source/solr/instance" override="true"/>
</Context>