Skip to main content
Jump to: navigation, search


< SMILA‎ | Documentation
Revision as of 03:46, 12 July 2011 by (Talk | contribs) (Default configuration: typos)

Solr is an open source search server based on the Lucene search engine. In addition to a powerful full-text-search, sorting and filtering, Solr comes with a lot of built-in features like highlighting, facets, auto-suggest and spell checking.

SolrServerManager & SolrProperties

Solr can run as stand alone remote server as well as embedded server within SMILA. There exist a properties file to control the running mode: configuration/org.eclipse.smila.solr/

##### If true SMILA load default configuration for an embedded Solr instance (see below) #####
##### Alternative workspace folder equals solr.home (embedded only) #####
##### Server url for http connections to Solr server (remote only) #####

Default configuration

SMILA supports Solr only in multicore setup (core is the solr word for a search index), regardless whether Solr runs embedded or remote.

The default configuration included in SMILA is defined in configuration/org.eclipse.smila.solr. The default mode is 'remote' in which case no internal solr server is started. However, the same folder contains a full solr multicore configuration that is used when the mode is set to embedded. This setup defines the sole DefaultCore holding that is suitable for the HowTo cases in SMILA.

More information about solr cores and their configuration can be found at:

If SMILA starts up for the first time and Solr is configured embedded, the configuration is copied to Solr workspace (solr.home).


One of the most import configuration files is configuration/org.eclipse.smila.solr/DefaultCore/conf/schema.xml. This file defines index fields and types. SMILA comes with the following set of predefined fields:

<field name="Id" type="string_id" indexed="true" stored="true" required="true" />
<field name="LastModifiedDate" type="date" indexed="true" stored="true" />
<field name="Filename" type="text_path" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
<field name="Path" type="text_path" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
<field name="Extension" type="textgen" indexed="true" stored="true" />
<field name="Size" type="long" indexed="true" stored="true" />
<field name="MimeType" type="textgen" indexed="true" stored="true" />
<field name="Content" type="textgen" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
<field name="Title" type="textgen" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
<field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true" />

The schema.xml also contains the uniqueKey property which Solr needs to know what field is used to id the documents and transparently handles add/updated accordingly. By default it is set to Id.

All other configuration possibilities like field types, default search field copy field and many more you can look up here:


Another major configuration file is configuration/org.eclipse.smila.solr/DefaultCore/conf/solfconfig.xml. This is the configuration for all SearchComponents, RequestHandlers and the general indexing and query configuration.

Please refer to its documentation here:

Important for SMILA is that in the embedded case the dataDir property defaults to the data/ sub folder of the core instance (e.i. solr.home/DefaultCore/data/. Hence, in embedded mode the SMILA workspace may grow quite large. Use this property in this file or set it through solr.xml at the core to provide an alternative location.

SMILA uses autoCommit via solr.DirectUpdateHandler2. It tells Solr to commit automatically every 60 seconds or after 1000 documents were added. If this property is not set, no commit will occur and the indexed data is not persistent or search-able unless you send appropriate solr commands yourself. The values are a compromise where these factors play a role: - how soon shall/must a user that searches see the updates? - how many update request are sent to solr ? Note, that during commit the solr server server stalls updates which might lead to index pipelet timeouts.

How to use Solr with SMILA

Indexing data

The SolrIndexPipelet can add, update or delete records (equates to Solr documents) in an index.

Configuration in addpipeline:

      <proc:invokePipelet name="SolrIndexPipelet">
        <proc:pipelet class="org.eclipse.smila.solr.index.SolrIndexPipelet" />
        <proc:variables input="request" output="request" />
          <!-- either ADD or DELETE. -->
          <rec:Val key="ExecutionMode">ADD</rec:Val>
          <!-- defines the default core into which the record will be written. optional, but if missing then the target core 
            must be set in the record via SolrConstants.DYNAMIC_TARGET_CORE -->
          <rec:Val key="CoreName">DefaultCore</rec:Val>
          <!-- seq of fields that are to be filled. each tuple is a map that defines the target core field, the source field 
            (optional) and the source type (optional ) -->
          <rec:Seq key="CoreFields">
              <!-- target field name in the solr core -->
              <rec:Val key="FieldName">Folder</rec:Val>
              <!-- name of the source attribute or attachment in the record. optional, defaults to the target field name -->
              <rec:Val key="RecSourceName">Path</rec:Val>
              <!-- either ATTRIBUTE or ATTACHMENT. optional, defaults to ATTIRBUTE. -->
              <rec:Val key="RecSourceType">ATTRIBUTE</rec:Val>
              <rec:Val key="FieldName">Filename</rec:Val>

Configuration in deletepipeline:

      <proc:invokePipelet name="SolrIndexPipelet">
        <proc:pipelet class="org.eclipse.smila.solr.index.SolrIndexPipelet" />
        <proc:variables input="request" output="request" />
          <rec:Val key="ExecutionMode">DELETE</rec:Val>
          <rec:Val key="CoreName">DefaultCore</rec:Val>


The SolrSearchPipelet offers the possibility to search indexed data on a Solr server. The pipelet needs only a small configuration without any special parameters.

      <proc:invokePipelet name="invokeSolrSearchPipelet">
        <proc:pipelet class="" />
        <proc:variables input="request" output="request" />

For full feature support a special kind of SearchRecord is required. The easiest way to create such a record is to use the SolrQueryBuilder. This class extends native QueryBuilder with methods to configure a Solr request and special Solr feature like highlighting or facets. To configure additional Solr features there exist adapter classes which give an overview of possible parameters. All Solr specific parameters are stored in a map within SearchRecord named _solr.query.

	 // create Solr specific query builder
    final SolrQueryBuilder builder = new SolrQueryBuilder();
    // set query
    // set start (equals offset, default: 0)
    // set rows (equals max count, default: 10)
    // set fields (equals result attributes, default: Id, score)
    final String[] fl = { "Path", "Size", "Content" };
    // add a filter query (example: size between 500 and 1000)
    builder.addFilterQuery("Size:[500 TO 1000]");
    // set shards
    final String[] shards = { "http://localhost:8983/solr", "http://remote-server:8983/solr" };
    // set request handler

More information about common query parameters:


To configure highlighting the HihglightingQueryConfigAdapter is used. The default constructor create a configuration object with global highlighting parameters which is required to enable highlighting. The other constructor provides an optional per-field configuration.

	 // create global highlighting configuration (required, enables highlighting)
    final HighlightingQueryConfigAdapter highlighting = new HighlightingQueryConfigAdapter();

More information about all highlighting parameters:


The FacetQueryConfigAdapter provide only one constructor but takes a FacetType parameter instead. At least there is one configuration of FacetType.GLOBAL required (global configuration) to enabled facets. The other types are FacetType.DATE, FacetType.FIELD and FacetType.QUERY which takes an Array of Strings.

    // create global facet configuration (required, enables facets)
    final FacetQueryConfigAdapter facet_global = new FacetQueryConfigAdapter(FacetType.GLOBAL);
    builder.addFacetConfiguration(SolrConstants.GLOBAL, facet_global);
    // create field facet configuration
    final FacetQueryConfigAdapter facet_field = new FacetQueryConfigAdapter(FacetType.FIELD);
    builder.addFacetConfiguration("Extension", facet_field);
    // create facet date configuration
    final FacetQueryConfigAdapter facet_date = new FacetQueryConfigAdapter(FacetType.DATE);
    builder.addFacetConfiguration("LastModifiedDate", facet_date);
    // create facet query configuration (range example)
    final String[] fq = { "* TO 1000", "1000 TO 5000", "5000 * TO" };
    final FacetQueryConfigAdapter facet_query = new FacetQueryConfigAdapter(FacetType.QUERY, fq);
    builder.addFacetConfiguration("Size", facet_query);

More on how different facet types and their parameter work:

Terms (Auto-suggest)

The TermsQueryConfigAdapeter comes with a default constructor which enables terms. To use the TermsComponent the RequestHandler must be set according to its configuration (solrconfig.xml, default: /terms).

	 // create terms configuration (auto suggest example)
    final TermsQueryConfigAdapter terms = new TermsQueryConfigAdapter("Title");

More information about terms configuration and parameters:

Spellcheck (Did you mean)

The default constructor of SpellCheckQueryConfigAdapter is required to enable SpellCheckComponent. In most cases it's useful to configure the default request handler to use SpellCheckComponent (solrconfig.xml). Otherwise the correct request handler must be set (solrconfig.xml example: /spell). By default SpellCheckComponent use a separate index which is created on the fly (in SMILAS's default configuration on every commit).

	 // create spell check configuration
    final SpellCheckQueryConfigAdapter spellcheck = new SpellCheckQueryConfigAdapter();

More information about SpellCheckComponent configuration and parameters:

SolrSearchRecord XML

With the aid of the SolrQueryBuilder and the adapters above the following Record structure will be created.

<?xml version="1.1" encoding="utf-8"?>
<Record xmlns="" version="2.0">
	<!-- query (q) -->
	<Val key="query">query</Val>
	<!-- start -->
	<Val key="offset" type="long">10</Val>
	<!-- rows -->
	<Val key="maxcount" type="long">5</Val>
	<!-- result field (fl) -->
	<Seq key="resultAttributes">
	<Map key="_solr.query">
		<!-- filter query (fq) -->
		<Seq key="fq">
			<Val>Size:[500 TO 1000]</Val>
		<!-- shards -->
		<Seq key="shards">
		<!-- request handler (qt) -->
		<Val key="qt">/terms</Val>
		<!-- highlighting configuration -->
		<Seq key="highlighting">
			<!-- a global map to enable highlighting -->
				<Val key="attribute">global.solr.params</Val>
				<Val key="hl" type="boolean">true</Val>
				<Val key="hl.fl">Content</Val>
				<Val key="hl.simple.pre">&lt;b&gt;</Val>
				<Val key="">&lt;/b&gt;</Val>
			<!-- other maps with attribute = field name for per-field configuration -->
		<!-- terms configuration -->
		<Map key="terms">
			<Val key="terms" type="boolean">true</Val>
			<Val key="terms.fl">Title</Val>
			<Val key="terms.lower">auto</Val>
			<Val key="terms.prefix">sug</Val>
		<!-- spell check configuration -->
		<Map key="spellcheck">
			<Val key="spellcheck" type="boolean">true</Val>
			<Val key="spellcheck.count" type="long">5</Val>
			<Val key="spellcheck.extendedResults" type="boolean">true</Val>
			<Val key="spellcheck.collate" type="boolean">true</Val>
	<!-- facet configuration -->
	<Seq key="groupby">
		<!-- a global map to enable facets -->
			<Val key="facet" type="boolean">true</Val>
			<Val key="attribute">global.solr.params</Val>
		<!-- per-field configuration for facet.field-->
			<Val key="_facet">facet.field</Val>
			<Val key="facet.limit" type="long">10</Val>
			<Val key="attribute">Extension</Val>
		<!-- per-field configuration for>
			<Val key="_facet"></Val>
			<Val key="">NOW/DAY-5DAYS</Val>
			<Val key="">+1DAY</Val>
			<Val key="">NOW/DAY+1DAY</Val>
			<Val key="attribute">LastModifiedDate</Val>
		<!-- per-field configuration for facet.query-->
			<Val key="_facet">facet.query</Val>
			<Seq key="_fc">
				<Val>* TO 1000</Val>
				<Val>1000 TO 5000</Val>
				<Val>5000 * TO</Val>
			<Val key="attribute">Size</Val>

Back to the top