FullText

This class implements the native full text search. Most methods can be called using SQL statements as well.

Methods
static void createIndex(Connection conn, String schema, String table, String columnList)
Create a new full text index for a table and column list.
static void createIndex(Connection conn, String schema, String table, String columnList) throws SQLException
Create a new full text index for a table and column list. Each table may only have one index at any time.
Parameters:
conn - the connection
schema - the schema name of the table (case sensitive)
table - the table name (case sensitive)
columnList - the column list (null for all columns)
static SimpleResultSet createResultSet(boolean data)
Create an empty search result and initialize the columns.
static SimpleResultSet createResultSet(boolean data) throws SQLException
Create an empty search result and initialize the columns.
Parameters:
data - true if the result set should contain the primary key data as an array.
Returns:
the empty result set
static void dropAll(Connection conn)
Drops all full text indexes from the database.
static void dropAll(Connection conn) throws SQLException
Drops all full text indexes from the database.
Parameters:
conn - the connection
static void dropIndex(Connection conn, String schema, String table)
Drop an existing full text index for a table.
static void dropIndex(Connection conn, String schema, String table) throws SQLException
Drop an existing full text index for a table. This method returns silently if no index for this table exists.
Parameters:
conn - the connection
schema - the schema name of the table (case sensitive)
table - the table name (case sensitive)
static void init(Connection conn)
Initializes full text search functionality for this database.
static void init(Connection conn) throws SQLException
Initializes full text search functionality for this database. This adds the following Java functions to the database:
  • FT_CREATE_INDEX(schemaNameString, tableNameString, columnListString)
  • FT_SEARCH(queryString, limitInt, offsetInt): result set
  • FT_REINDEX()
  • FT_DROP_ALL()
It also adds a schema FT to the database where bookkeeping information is stored. This function may be called from a Java application, or by using the SQL statements:
 CREATE ALIAS IF NOT EXISTS FT_INIT FOR
      "org.h2.fulltext.FullText.init";
 CALL FT_INIT();
Parameters:
conn - the connection
static Object[][] parseKey(Connection conn, String key)
Parse a primary key condition into the primary key columns.
static Object[][] parseKey(Connection conn, String key) throws SQLException
Parse a primary key condition into the primary key columns.
Parameters:
conn - the database connection
key - the primary key condition as a string
Returns:
an array containing the column name list and the data list
static void reindex(Connection conn)
Re-creates the full text index for this database
static void reindex(Connection conn) throws SQLException
Re-creates the full text index for this database
Parameters:
conn - the connection
static void removeAllTriggers(Connection conn, String prefix)
Remove all triggers that start with the given prefix.
static void removeAllTriggers(Connection conn, String prefix) throws SQLException
Remove all triggers that start with the given prefix.
Parameters:
conn - the database connection
prefix - the prefix
static ResultSet search(Connection conn, String text, int limit, int offset)
Searches from the full text index for this database.
static ResultSet search(Connection conn, String text, int limit, int offset) throws SQLException
Searches from the full text index for this database. The returned result set has the following column:
  • QUERY (varchar): the query to use to get the data. The query does not include 'SELECT * FROM '. Example: PUBLIC.TEST WHERE ID = 1
Parameters:
conn - the connection
text - the search query
limit - the maximum number of rows or 0 for no limit
offset - the offset or 0 for no offset
Returns:
the result set
static ResultSet searchData(Connection conn, String text, int limit, int offset)
Searches from the full text index for this database.
static ResultSet searchData(Connection conn, String text, int limit, int offset) throws SQLException
Searches from the full text index for this database. The result contains the primary key data as an array. The returned result set has the following columns:
  • SCHEMA (varchar): the schema name. Example: PUBLIC
  • TABLE (varchar): the table name. Example: TEST
  • COLUMNS (array of varchar): comma separated list of quoted column names. The column names are quoted if necessary. Example: (ID)
  • KEYS (array of values): comma separated list of values. Example: (1)
Parameters:
conn - the connection
text - the search query
limit - the maximum number of rows or 0 for no limit
offset - the offset or 0 for no offset
Returns:
the result set
static void setColumns(int[] index, ArrayList keys, ArrayList columns)
Set the column indices of a set of keys.
static void setColumns(int[] index, ArrayList keys, ArrayList columns) throws SQLException
Set the column indices of a set of keys.
Parameters:
index - the column indices (will be modified)
keys - the key list
columns - the column list
static void setIgnoreList(Connection conn, String commaSeparatedList)
Change the ignore list.
static void setIgnoreList(Connection conn, String commaSeparatedList) throws SQLException
Change the ignore list. The ignore list is a comma separated list of common words that must not be indexed. The default ignore list is empty. If indexes already exist at the time this list is changed, reindex must be called.
Parameters:
conn - the connection
commaSeparatedList - the list