FullTextLucene

This class implements the full text search based on Apache Lucene. 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 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 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:
  • FTL_CREATE_INDEX(schemaNameString, tableNameString, columnListString)
  • FTL_SEARCH(queryString, limitInt, offsetInt): result set
  • FTL_REINDEX()
  • FTL_DROP_ALL()
It also adds a schema FTL 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 FTL_INIT FOR
      "org.h2.fulltext.FullTextLucene.init";
 CALL FTL_INIT();
Parameters:
conn - the connection
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 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