Search

Jetspeed-2 provides an integration with the popular Apache Lucene search engine and Apache Solr search engine, high-performance, full-featured text search engine libraries; technologies suitable for nearly any application that requires full-text search, especially cross-platform. You can either embed Solr based search engine component in Jetspeed-2 or connect to an external Solr engine via http connection. By default, Apache Lucene based search engine component is used, but you can switch to Solr based search engine component easily by copying one of alternate Spring xml confiugration files.

By default, Jetspeed-2 indexes all registry information: portlet instances and portlet definitions as searchable entities.

Default Lucene based search engine configuration

Configuration for the Search Engine is in the Spring configuration file search.xml You can configure the location of your search indices in this Spring configuration file. Note you may want to move the location of your indices outside the Jetspeed web application

	
  <bean id="org.apache.jetspeed.search.SearchEngine"
  	class="org.apache.jetspeed.search.lucene.SearchEngineImpl"
  >
  	<constructor-arg index="0"><value>${applicationRoot}/WEB-INF/search_index</value></constructor-arg>
  	....

Embedded Solr based search engine configuration

If you copy /WEB-INF/assembly/alternate/search-embedded-solr-override.xml to /WEB-INF/assembly/override/ folder, you can switch to an embedded Solr based search engine component instead of the default Lucene based one.

   
  ....
  
  <bean id="org.apache.solr.core.CoreContainer" class="org.apache.solr.core.CoreContainer" destroy-method="shutdown">
    <meta key="j2:cat" value="default or search" />
    <constructor-arg value="${search.embedded.solr.solr.home}" />
    <constructor-arg>
      <bean class="java.io.File">
        <meta key="j2:cat" value="default or search" />
        <constructor-arg value="${search.embedded.solr.solr.home}/solr.xml" />
      </bean>
    </constructor-arg>
  </bean>
  
  <bean id="org.apache.solr.client.solrj.SolrServer" class="org.apache.solr.client.solrj.embedded.EmbeddedSolrServer" depends-on="_embeddedSolrDataDirPropSetter">
    <meta key="j2:cat" value="default or search" />
    <constructor-arg ref="org.apache.solr.core.CoreContainer" />
    <constructor-arg value="js" />
  </bean>
  
  <bean id="org.apache.jetspeed.search.SearchEngine" class="org.apache.jetspeed.search.solr.SolrSearchEngineImpl">
    <meta key="j2:cat" value="default or search" />
    <constructor-arg ref="org.apache.solr.client.solrj.SolrServer" />
    <constructor-arg type="boolean" value="${search.index.optimizeAfterUpdate}" />
    <constructor-arg ref="org.apache.jetspeed.search.HandlerFactory" />
  </bean>

In the example configuration above, the embedded Solr based search engine component will initialize search index as configured by properties in /WEB-INF/conf/jetspeed.properties:

   
# Optionally you can configure embedded solr home and data dir paths 
# if you enable embedded solr instead of the default lucene
search.embedded.solr.solr.home=${applicationRoot}/WEB-INF/solr
search.embedded.solr.data.dir=${applicationRoot}/WEB-INF/solr/data

The Solr configurations are located in /WEB-INF/solr directory. For more extensibility, it is provided as multi-core setup as follows:

   
<solr persistent="true">
  <cores adminPath="/admin/cores">
    <core name="js" instanceDir="js"></core>
  </cores>
</solr>                    

External Solr based search engine configuration

If you copy /WEB-INF/assembly/alternate/search-http-solr-override.xml to /WEB-INF/assembly/override/ folder, you can switch to an external Solr based search engine component instead of the default Lucene based one.

  ....   
  
  <bean id="org.apache.solr.client.solrj.SolrServer" class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer">
    <meta key="j2:cat" value="default or search" />
    <constructor-arg value="${search.http.solr.url}" />
    <property name="soTimeout" value="1000" />
    <property name="connectionTimeout" value="100" />
    <property name="defaultMaxConnectionsPerHost" value="100" />
    <property name="maxTotalConnections" value="100" />
    <property name="followRedirects" value="false" />
    <property name="allowCompression" value="true" />
    <property name="maxRetries" value="1" />
    <property name="parser">
      <bean class="org.apache.solr.client.solrj.impl.XMLResponseParser">
        <meta key="j2:cat" value="default or search" />
      </bean>
    </property>
  </bean>
  
  <bean id="org.apache.jetspeed.search.SearchEngine" class="org.apache.jetspeed.search.solr.SolrSearchEngineImpl">
    <meta key="j2:cat" value="default or search" />
    <constructor-arg ref="org.apache.solr.client.solrj.SolrServer" />
    <constructor-arg type="boolean" value="${search.index.optimizeAfterUpdate}" />
    <constructor-arg ref="org.apache.jetspeed.search.HandlerFactory" />
  </bean>
  
  ....

In the example configuration above, the Solr based search engine component will connect to the external Solr engine as configured by properties in /WEB-INF/conf/jetspeed.properties:

   
# Optionally you can configure external solr http(s) url
# Note: If you have multi-core setup, you should put the core name at the end. e.g., '/js'.
search.http.solr.url=http://localhost:8983/solr/js

Solr based search schema confiugration

An example schema configuration for Jetspeed-2 can be found in /WEB-INF/solr/js/conf/schema.xml. Jetspeed-2 requires the following fields at least:

   
   <!-- Core Search Fields -->
   <field name="fieldname.key" type="string" indexed="true" stored="true" required="true" />
   <field name="fieldname.type" type="text" indexed="true" stored="true" required="false" />
   <field name="fieldname.content" type="text" indexed="true" stored="false" required="false" />
   <field name="fieldname.description" type="text" indexed="true" stored="true" multiValued="true" required="false" />
   <field name="fieldname.title" type="text" indexed="true" stored="true" multiValued="true" required="false" />
   <field name="fieldname.language" type="text" indexed="true" stored="true" multiValued="true" required="false" />
   <field name="fieldname.fields" type="text" indexed="true" stored="false" multiValued="true" required="false" />
   <field name="fieldname.keywords" type="string" indexed="true" stored="true" multiValued="true" required="false" />
   <field name="fieldname.url" type="text" indexed="true" stored="true" multiValued="true" required="false" />
   <field name="fieldname.score" type="text" indexed="true" stored="false" required="false" />
   <field name="fieldname.className" type="text" indexed="true" stored="true" required="false" />
   <field name="fieldname.synthetic" type="text" indexed="true" stored="false" required="false" />
   <!-- Metadata Search Fields -->
   <field name="ID" type="string" indexed="true" stored="true" required="false" />
   <field name="url" type="text" indexed="true" stored="true" required="false" />
   <field name="portlet" type="string" indexed="true" stored="true" required="false" />
   <field name="portlet_application" type="string" indexed="true" stored="true" required="false" />
   <field name="title" type="string" indexed="true" stored="false" multiValued="true" required="false" />
   <field name="description" type="string" indexed="true" stored="false" multiValued="true" required="false" />
   <field name="subject" type="string" indexed="true" stored="false" multiValued="true" required="false" />
   <field name="creator" type="string" indexed="true" stored="false" multiValued="true" required="false" />
   <field name="publisher" type="string" indexed="true" stored="false" multiValued="true" required="false" />
   <field name="contributor" type="string" indexed="true" stored="false" multiValued="true" required="false" />
Therefore, please be sure that the schema should be configured properly like the example above when you want to use an external Solr search engine.

If you want easy steps to test an external Solr based search engine component, here are simple ones as an example:

  1. Copy /WEB-INF/assembly/alternate/search-http-solr-override.xml to /WEB-INF/assembly/override/ folder.
  2. Instal Solr war file onto a servlet container. For example, copy solr.war to $CATALINA_HOME/webapps/.
  3. Copy the example Solr home and data directory to somewhere you want to keep the search index. For example, copy /jetspeed/WEB-INF/solr/ directory to /tmp/solr/.
  4. Start the servlet container with specifying Solr home and data directory.

    $ export CATALINA_OPTS="-Xmx256m -XX:MaxPermSize=128m -Dsolr.solr.home=/tmp/solr -Dsolr.data.dir=/tmp/solr/data"
  5. If you didn't deploy portlet applications again and the search index was not refreshed, then redeploy all the portlet applications or refresh the search index for each portlet application in the Portlet Application Manager portlet.

Search UIs

Registry Applications List Portlet in Portlet Application Manager Page



Application Details Portlet in Portlet Application Manager Page



You can refresh search index for each application.