Crafter Search Setup

compared with
Current by Michiel Verkaik
on Oct 24, 2012 11:14.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (9)

View Page History
h3. Solr Server Setup
{toc:style=none}

{info:title=Availability}This document discusses a feature that is currently in development. You can work with this capability in it's development and beta stages by downloading and building the Trunk source code.{info}

h4. Solr Server Setup

The Crafter Engine full-text search is provided by Apache Solr Server. Solr can be downloaded *[here|http://lucene.apache.org/solr/downloads.html]* (version 3.5 or higher). For development, you may use the example Solr server in the _./example_ folder. Otherwise, the Solr server itself is in a WAR file, for example, _apache-solr-3.5.0/dist/apache-solr-3.5.0.war_.

h4. Crafter Engine Configuration

Crafter Engine here refers to the one in _cstudio-trunk/cengine/cengine-war/target/ROOT.war_ deployed in Crafter Studio or its preview server. This WAR comes with a Spring MVC controller for Solr search (available in Crafter Studio 2.0.1). The key settings in _webapps/ROOT/WEB-INF/classes/crafter/base-context.xml_ are (already in 2.0.1 build, shown here as a reference):

{code}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
...
<bean id="crafter.rendering.searchService"
        class="org.rivetlogic.crafter.rendering.spring.mvc.service.SearchService">
        <property name="solrServerUrl" value="${crafter.solrServerUrl}"/>
        <property name="descriptorService" ref="crafter.rendering.descriptorService" />
    </bean>
The Solr search engine can be configured to run in the same Tomcat instance as Crafter Studio or in a separate instance of Tomcat. For the latter case, if the Solr server is not running at localhost:8983, set {{crafter.solrServerUrl}} accordingly in _shared/classes/crafter/cengine/extension/server-config.properties_. Be sure to include the application path "/solr" at the end, for example:

    <bean id="crafter.searchController"
        class="org.rivetlogic.crafter.rendering.spring.mvc.controller.SearchController">
        <property name="searchService" ref="crafter.rendering.searchService"/>
    </bean>
...
<bean id="crafter.rendering.renderingControllersMapping"
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="order"
            value="${crafter.rendering.page.controller.mapping.order}" />
        <property name="urlMap">
            <map>
                <entry key="/search" value-ref="crafter.searchController" />
                <entry key="/*" value-ref="crafter.rendering.pageRenderingController" />
                <!-- entry key="/{path}" value-ref="crafter.rendering.pageRenderingController"/ -->
            </map>
        </property>
    </bean>
...
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
...
<property name="viewResolvers">
<list>
<ref bean="crafter.rendering.pageViewResolver" />
<ref bean="crafter.rendering.freeMarkerViewResolver" />
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="prefix" value="/templates/web/"/>
<property name="suffix" value=".ftl"/>
<property name="viewNames">
<list>
<value>search</value>
</list>
</property>
</bean>
</list>
</property>
...
</bean>
...
{code}
If the Solr server is not running in localhost:8983, set {{crafter.solrServerUrl}} accordingly in _shared/classes/crafter/cengine/extension/server-config.properties_. Be sure to include the application path "/solr" at the end, for example:

{code}
crafter.solrServerUrl=http://search.acme.com:8180/solr
crafter.core.cache=false
crafter.core.store.filesystem.rootFolder.path=/opt/cstudio-2.0.0/tomcat/preview-content/data/wem-projects/acmecom/acmecom/work-area
{code}