org.h2.fulltext
Class FullTextLucene

java.lang.Object
  extended by org.h2.fulltext.FullText
      extended by org.h2.fulltext.FullTextLucene

public class FullTextLucene
extends FullText

This class implements the full text search based on Apache Lucene. Most methods can be called using SQL statements as well.


Nested Class Summary
static class FullTextLucene.FullTextTrigger
          Trigger updates the index when a inserting, updating, or deleting a row.
 
Constructor Summary
FullTextLucene()
           
 
Method Summary
static void createIndex(java.sql.Connection conn, java.lang.String schema, java.lang.String table, java.lang.String columnList)
          Create a new full text index for a table and column list.
static void dropAll(java.sql.Connection conn)
          Drops all full text indexes from the database.
static void init(java.sql.Connection conn)
          Initializes full text search functionality for this database.
static void reindex(java.sql.Connection conn)
          Re-creates the full text index for this database.
static java.sql.ResultSet search(java.sql.Connection conn, java.lang.String text, int limit, int offset)
          Searches from the full text index for this database.
static java.sql.ResultSet searchData(java.sql.Connection conn, java.lang.String text, int limit, int offset)
          Searches from the full text index for this database.
 
Methods inherited from class org.h2.fulltext.FullText
asString, createResultSet, dropIndex, parseKey, quoteSQL, removeAllTriggers, setColumns, setIgnoreList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FullTextLucene

public FullTextLucene()
Method Detail

init

public static void init(java.sql.Connection conn)
                 throws java.sql.SQLException
Initializes full text search functionality for this database. This adds the following Java functions to the database: 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
Throws:
java.sql.SQLException

createIndex

public static void createIndex(java.sql.Connection conn,
                               java.lang.String schema,
                               java.lang.String table,
                               java.lang.String columnList)
                        throws java.sql.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)
Throws:
java.sql.SQLException

reindex

public static void reindex(java.sql.Connection conn)
                    throws java.sql.SQLException
Re-creates the full text index for this database.

Parameters:
conn - the connection
Throws:
java.sql.SQLException

dropAll

public static void dropAll(java.sql.Connection conn)
                    throws java.sql.SQLException
Drops all full text indexes from the database.

Parameters:
conn - the connection
Throws:
java.sql.SQLException

search

public static java.sql.ResultSet search(java.sql.Connection conn,
                                        java.lang.String text,
                                        int limit,
                                        int offset)
                                 throws java.sql.SQLException
Searches from the full text index for this database. The returned result set has the following column:

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
Throws:
java.sql.SQLException

searchData

public static java.sql.ResultSet searchData(java.sql.Connection conn,
                                            java.lang.String text,
                                            int limit,
                                            int offset)
                                     throws java.sql.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:

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
Throws:
java.sql.SQLException