Description:
The following guide helps you do the following:
- Add all Solr components to an existing RADiX deployment (i.e. solr catalog, solr war, OODT File Manger Solr catalog)
- Configure an existing OODT RADiX File Manager to use Solr as the native catalog
Directions:
- Download Solr (4.2.1) and place it within RADiX project source as top-level folder
- Package it inside a maven folder structure. For an overview of, see: http://fusesource.com/docs/esb/4.2/deploy_osgi/Build-MavenDir.html
- NOTE: you only need to place the contents of the solr/examples/solr directory inside of your solr/src/main/resources. Everything else that comes in the solr tar-ball can be ignored
- Change the name of the solr core 'collection1' to something you'd prefer (e.g. 'oodt-fm')
- Rename the directory: solr/src/main/resources/collection1
- Replace instances of 'collection1' inside solr/src/main/assembly/assembly.xml
- Replace instances of 'collection1' inside solr/src/main/resources/collection1/core.properties
- Package it inside a maven folder structure. For an overview of, see: http://fusesource.com/docs/esb/4.2/deploy_osgi/Build-MavenDir.html
- Add an overlay for solr webapp, within webapps folder of RADiX. In other words, create a new webapp Maven2 project
- Create a new directory under webapps, with the following directory structure:
Code Block bash-3.2$ tree . ├── pom.xml └── src └── main └── webapp ├── META-INF │ └── context.xml └── WEB-INF └── web.xml
- Create a new pom.xml, filling in entries with the below template:
Code Block <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.mycompany.myapp</groupId> <artifactId>oodt-radix-myapp</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> <name>Apache Solr Webapp</name> <artifactId>myapp-solr-webapp</artifactId> <packaging>war</packaging> <build> <sourceDirectory>src/main/java</sourceDirectory> <testSourceDirectory>src/test</testSourceDirectory> <outputDirectory>target/classes</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**</include> </includes> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <overlays> <overlay> <groupId>org.apache.solr</groupId> <artifactId>solr</artifactId> </overlay> </overlays> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr</artifactId> <version>4.2.1</version> <type>war</type> </dependency> </dependencies> </project>
- Create the assembly.xml file
Code Block <!--<assembly> <id>bin</id> <formats> <format>tar.gz</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <baseDirectory>solr</baseDirectory> <includeSiteDirectory>false</includeSiteDirectory> <fileSets> <fileSet> <directory>${basedir}</directory> <outputDirectory>.</outputDirectory> <includes> <include>README.txt</include> <include>solr.xml</include> <include>zoo.cfg</include> </includes> <fileMode>775</fileMode> </fileSet> <fileSet> <directory>${basedir}/bin</directory> <outputDirectory>solr/bin</outputDirectory> <includes/> <fileMode>775</fileMode> </fileSet> <fileSet> <directory>${basedir}/collection1</directory> <outputDirectory>solr/collection1</outputDirectory> <includes> <include>**/*</include> </includes> <fileMode>664</fileMode> <directoryMode>775</directoryMode> </fileSet> </fileSets> </assembly> -->
- Create the context.xml file:
Code Block <?xml version="1.0" encoding="utf-8"?> <Context path="/solr"> <Parameter name="solr/home" value="../solr"/> </Context>
- Add the web.xml file:
Code Block <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5" metadata-complete="true" > <!-- Uncomment if you are trying to use a Resin version before 3.0.19. Their XML implementation isn't entirely compatible with Xerces. Below are the implementations to use with Sun's JVM. <system-property javax.xml.xpath.XPathFactory= "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"/> <system-property javax.xml.parsers.DocumentBuilderFactory= "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/> <system-property javax.xml.parsers.SAXParserFactory= "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"/> --> <!-- People who want to hardcode their "Solr Home" directly into the WAR File can set the JNDI property here... --> <env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>../solr</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> <!-- Any path (name) registered in solrconfig.xml will be sent to that filter --> <filter> <filter-name>SolrRequestFilter</filter-name> <filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class> <!-- If you are wiring Solr into a larger web application which controls the web context root, you will probably want to mount Solr under a path prefix (app.war with /app/solr mounted into it, for example). You will need to put this prefix in front of the SolrDispatchFilter url-pattern mapping too (/solr/*), and also on any paths for legacy Solr servlet mappings you may be using. For the Admin UI to work properly in a path-prefixed configuration, the admin folder containing the resources needs to be under the app context root named to match the path-prefix. For example: .war xxx js main.js --> <!-- <init-param> <param-name>path-prefix</param-name> <param-value>/xxx</param-value> </init-param> --> </filter> <filter-mapping> <!-- NOTE: When using multicore, /admin JSP URLs with a core specified such as /solr/coreName/admin/stats.jsp get forwarded by a RequestDispatcher to /solr/admin/stats.jsp with the specified core put into request scope keyed as "org.apache.solr.SolrCore". It is unnecessary, and potentially problematic, to have the SolrDispatchFilter configured to also filter on forwards. Do not configure this dispatcher as <dispatcher>FORWARD</dispatcher>. --> <filter-name>SolrRequestFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>Zookeeper</servlet-name> <servlet-class>org.apache.solr.servlet.ZookeeperInfoServlet</servlet-class> </servlet> <servlet> <servlet-name>LoadAdminUI</servlet-name> <servlet-class>org.apache.solr.servlet.LoadAdminUiServlet</servlet-class> </servlet> <!-- Remove in Solr 5.0 --> <!-- This sends SC_MOVED_PERMANENTLY (301) for resources that changed in 4.0 --> <servlet> <servlet-name>RedirectOldAdminUI</servlet-name> <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> <init-param> <param-name>destination</param-name> <param-value>${context}/#/</param-value> </init-param> </servlet> <servlet> <servlet-name>RedirectOldZookeeper</servlet-name> <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> <init-param> <param-name>destination</param-name> <param-value>${context}/zookeeper</param-value> </init-param> </servlet> <servlet> <servlet-name>RedirectLogging</servlet-name> <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> <init-param> <param-name>destination</param-name> <param-value>${context}/#/~logging</param-value> </init-param> </servlet> <servlet> <servlet-name>SolrRestApi</servlet-name> <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class> <init-param> <param-name>org.restlet.application</param-name> <param-value>org.apache.solr.rest.SolrRestApi</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>RedirectOldAdminUI</servlet-name> <url-pattern>/admin/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RedirectOldAdminUI</servlet-name> <url-pattern>/admin</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RedirectOldZookeeper</servlet-name> <url-pattern>/zookeeper.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RedirectLogging</servlet-name> <url-pattern>/logging</url-pattern> </servlet-mapping> <!-- Servlet Mapping --> <servlet-mapping> <servlet-name>Zookeeper</servlet-name> <url-pattern>/zookeeper</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LoadAdminUI</servlet-name> <url-pattern>/admin.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>SolrRestApi</servlet-name> <url-pattern>/schema/*</url-pattern> </servlet-mapping> <mime-mapping> <extension>.xsl</extension> <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ --> <mime-type>application/xslt+xml</mime-type> </mime-mapping> <welcome-file-list> <welcome-file>admin.html</welcome-file> </welcome-file-list> </web-app>
- If using Solr 4.3+, make sure to set up logging properly
- In your webapp's top-level pom.xml, add the following entries
Code Block <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.6</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1.6.6</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jul-to-slf4j</artifactId> <version>1.6.6</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.6</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency>
- Place the Solr config directory's solr/example/resources/log4j.properties in a new directory under your webapp: solr/src/main/webapp/WEB-INF/lib
- In your webapp's top-level pom.xml, add the following entries
- Create a new directory under webapps, with the following directory structure:
- Include Solr webapp in overall build
- Make sure your solr webapp module is referenced within the top-leve RADiX folder's webapps/pom.xml
- Within the distribution folder's pom.xml, include the Solr webapp inside the pom.xml
- e.g.:
Code Block <dependency> <groupId>com.mycompany.myapp</groupId> <artifactId>myapp-solr-webapp</artifactId> <version>${project.parent.version}</version> <type>war</type> </dependency>
- e.g.:
- Within the distribution folder's pom.xml, include the Solr webapp in the pom.xml as a build artifact
- e.g.:
Code Block <artifactItem> <groupId>com.mycompany.myapp</groupId> <artifactId>${parent.artifactId}-solr-webapp</artifactId> <type>war</type> <overWrite>false</overWrite> <outputDirectory>${project.build.directory}/apache-tomcat-${tomcat.version}/webapps/solr</outputDirectory> </artifactItem>
- e.g.:
- Within the distribution folder's assembly folder, exclude the Solr webapp within assembly.xml
e.g.:
Code Block <exclude>${groupId}:${parent.artifactId}-solr-webapp</exclude>
- Include Solr config folder in overall build
- Within the top-level pom.xml, include the solr module within the maven build
- e.g.:
<module>solr</module>
- e.g.:
- Within the distribution folder's pom.xml, include the Solr config folder module inside
- e.g.:
<dependency>
<groupId>com.mycompany.myapp</groupId>
<artifactId>myapp-solr</artifactId>
<version>${project.parent.version}</version>
<type>tar.gz</type>
<classifier>bin</classifier>
</dependency>
- e.g.:
- Within the distribution/src/main/resources/bin/env.sh, include a reference to SOLR_HOME
- e.g.:
Code Block if [ -z "$SOLR_HOME" ]; then SOLR_HOME="$OODT_HOME"/solr export SOLR_HOME fi
- e.g.:
- Within the top-level pom.xml, include the solr module within the maven build
- Configure OODT to use Solr as backend file manager catalog
- Modify filemgr.properties to point to Solr catalog factory (see: )
- Copy over filemgr/etc/schema.xml to the Solr directory and overwrite the existing schema.xml
- Build OODT RADiX at the top level, to test your new setup:
Code Block mvn clean package