This guide describes how to add Text Indexes using Microsoft SQL Server. For information on how to handle Text Indexes on Oracle DB, see Cookbook - Oracle Text Index (valid to 7.10).
The configuration of table columns for Text Indexes using SQL Server differs to Oracle.
In the cartridge dbinit.properties file where the database table is created add the following preparer:
post.ClassXX = com.intershop.beehive.core.dbinit.preparer.database.TextIndexPreparer
It is required to specify the table columns which are desired to be included in the Text Index. Add this configuration to the cartridge-specific properties file:
################################################################################ # text index configuration ################################################################################ intershop.cartridges.text_index.<<table_name>>=<<LIST,OF,COLUMNS>>
The property key consists of the prefix intershop.cartridges.text_index.
and the table name (in uppercase letters). The value of this key is the list of included columns. Multiple column names can be delimited by a comma.
Note
For every table only a single Text index can be created. So all required index columns need to be added into one index.
To provide a custom index configuration, create a Java class implementing the interface com.intershop.beehive.core.capi.jdbc.TextIndexColumnsProvider
:
package com.intershop.beehive.core.capi.jdbc; import java.sql.SQLException; import java.util.Collection; /** * Classes implementing this interface return a collection of Strings * representing the columns to be included in the text index */ public interface TextIndexColumnsProvider { public static final String NAME_SUFFIX = "_TextIndexColumnsProvider"; public static final String GENERAL_PROVIDER = "GeneralTextIndexColumnsProvider"; /** * defines columns included in Text Index for given table * @param tableName the name of the table * @return Collection of columns * @throws SQLException */ Collection<String> getColumns(String tableName) throws SQLException; }
The method getColumns(String tableName)
will return the list of column names included in the Text Index. For an example see class com.intershop.beehive.core.internal.jdbc.XMLAttributesTextIndexColumnsProvider
which provides the column names for XMLExtensibleObjectPO
.
Bind this class to the TextIndexColumnsProvider
using Guice:
bind(TextIndexColumnsProvider.class).annotatedWith(Names.named(<<table_name>> + TextIndexColumnsProvider.NAME_SUFFIX)).to(<<your_provider_class_name>>.class).in(Singleton.class);
Ensure that this binding is annotated with your table name so that the class will be found later by the preparer.