Using Apache Solr for Content Search

Concept

iKnowBase comes with ready-to-use components for integration with the Apache Solr open source enterprise search platform ( http://lucene.apache.org/solr/).

When using iKnowBase together with Apache Solr, the following components will be in use:

The process for indexing works somewhat like this:

The process for search works somewhat like this:

Installation and setup

See the Installation Guide for installation guidelines.
After you’re done with the installation you are ready to index your content.

iKnowBase security

The Apache Solr Search Server, which is distributed together with iKnowBase, includes iKnowBase Solr components which handle security in terms of authorized access to documents. The iKnowBase security search component is configured in the configuration file “solrconfig.xml”, and configured for use by the search handler “/select”. Search handlers, which use this component, will load security information from iKnowBase and filter the result set by iKnowBase access control lists.

Note: If you will configure new search handlers, include the iKnowBase security search component to ensure authorized access to iKnowBase data. For information regarding security in autocomplete operations, see Configuring search suggestions below.

Configuring the indexing process

Before you start indexing your content you need to decide the following:

Building a search page

To build a search page, you will use a Groovy-based template (HtmlViewer, ScriptViewer or ScriptAction), where the iKnowBase SolrSearchClient component provides access to the Solrj library.

The basic flow for a search page is as follows, see below for examples:

Create unique package- and class names in every template to avoid conflicts with other solr templates. Use a descriptive name and avoid using com.iknowbase.

.bc package no.customer.intranet;
import org.apache.solr.client.solrj.SolrQuery;
def facets = [ “type_${context.language}”, “status_${context.language}”, “title”];
def sortFields = [ “document_id”, “type_${context.language}”, “updated_index_store_date” ];
new SolrjSearchClass (searchClients.default, html, context, facets, sortFields).run();

To merge a result set with a iKnowBase SOLR Viewer you first need to define a SOLR viewer with a SOLR presentation style. Then in the Groovy based template, you combine like this :

def rowset = this.searchClient.getRowSet(response, "<External key to the SOLR Viewer");
    for (int i=0 ; i<response.results.size() ; i++) {
        renderDocument (response.results[i], rowset.rows[i]);
    }

In renderDocument, you will have access to data from both SOLR and the Viewer. e.g.

def renderDocument(document, ikbRow) {
       ul {
                li("description=${document.description}");
                li("ikb.title=${ikbRow.document.title}");
                ikbRow.items.each { key, item ->
                    li {
                        mkp.yield(key + ": ");
                        mkp.yieldUnescaped (item.getAsString() ?: "")
                    }
                }
            }

In terms of documentation, you will be interested in the following:

Sample search page structure

A transport set is provided as an example where a basic search page is included with faceting, ordering and autocomplete based on a facet search. Import the file
etc/EXP-IKB_MASTER_67-F250F353F65159F3E040000A18007A88-iKnowBase-Demo-SolrExample.dmp from /ikbStudio/advanced/importjobs. It contains the “essentials” for using a search client in the page /demo/solr.

Configuring search suggestions

Search suggestions (autocomplete) can be implemented in several ways.

On the provided sample page, see chapter Sample search page structure, autocomplete is implemented using a faceted search. On the search page there is an Ext JS combobox which loads data through an iKnowBase script action. The script action forwards an autocomplete request, which actually is a faceted search, to Solr. Note: The property facetMinCount is set to 1 to prevent unauthorized access to data, ie. a facet is only returned if it is in use in one of the documents available to the user.

The Solr Suggester component provides an alternative way to implement autocomplete. Note: The Solr Suggester provides no mechanism to add a security filter and the user may get access to unathorized data, ie. if the completion comes from the title index, the user may see a document title even though he is not authoarized to view the document.

Monitoring the Solr solution

A few key items to check: