public class FullText
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FullText.FullTextTrigger
Trigger updates the index when a inserting, updating, or deleting a row.
|
Constructor and Description |
---|
FullText() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addWords(org.h2.fulltext.FullTextSettings setting,
java.util.Set<java.lang.String> set,
java.io.Reader reader)
Add all words in the given text to the hash set.
|
protected static void |
addWords(org.h2.fulltext.FullTextSettings setting,
java.util.Set<java.lang.String> set,
java.lang.String text)
Add all words in the given text to the hash set.
|
protected static java.lang.String |
asString(java.lang.Object data,
int type)
INTERNAL.
|
static void |
closeAll()
INTERNAL
Close all fulltext settings, freeing up memory.
|
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.
|
protected static SimpleResultSet |
createResultSet(boolean data)
Create an empty search result and initialize the columns.
|
static void |
dropAll(java.sql.Connection conn)
Drops all full text indexes from the database.
|
static void |
dropIndex(java.sql.Connection conn,
java.lang.String schema,
java.lang.String table)
Drop an existing full text index for a table.
|
protected static boolean |
hasChanged(java.lang.Object[] oldRow,
java.lang.Object[] newRow,
int[] indexColumns)
Check if a the indexed columns of a row probably have changed.
|
static void |
init(java.sql.Connection conn)
Initializes full text search functionality for this database.
|
protected static java.lang.String[][] |
parseKey(java.sql.Connection conn,
java.lang.String key)
Parse a primary key condition into the primary key columns.
|
protected static java.lang.String |
quoteSQL(java.lang.Object data,
int type)
INTERNAL.
|
static void |
reindex(java.sql.Connection conn)
Re-creates the full text index for this database.
|
protected static void |
removeAllTriggers(java.sql.Connection conn,
java.lang.String prefix)
Remove all triggers that start with the given prefix.
|
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.
|
protected static java.sql.ResultSet |
search(java.sql.Connection conn,
java.lang.String text,
int limit,
int offset,
boolean data)
Do the search.
|
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.
|
protected static void |
setColumns(int[] index,
java.util.ArrayList<java.lang.String> keys,
java.util.ArrayList<java.lang.String> columns)
Set the column indices of a set of keys.
|
static void |
setIgnoreList(java.sql.Connection conn,
java.lang.String commaSeparatedList)
Change the ignore list.
|
static void |
setWhitespaceChars(java.sql.Connection conn,
java.lang.String whitespaceChars)
Change the whitespace characters.
|
protected static java.sql.SQLException |
throwException(java.lang.String message)
Throw a SQLException with the given message.
|
public static void init(java.sql.Connection conn) throws java.sql.SQLException
CREATE ALIAS IF NOT EXISTS FT_INIT FOR "org.h2.fulltext.FullText.init"; CALL FT_INIT();
conn
- the connectionjava.sql.SQLException
- on failurepublic static void createIndex(java.sql.Connection conn, java.lang.String schema, java.lang.String table, java.lang.String columnList) throws java.sql.SQLException
conn
- the connectionschema
- the schema name of the table (case sensitive)table
- the table name (case sensitive)columnList
- the column list (null for all columns)java.sql.SQLException
- on failurepublic static void reindex(java.sql.Connection conn) throws java.sql.SQLException
conn
- the connectionjava.sql.SQLException
- on failurepublic static void dropIndex(java.sql.Connection conn, java.lang.String schema, java.lang.String table) throws java.sql.SQLException
conn
- the connectionschema
- the schema name of the table (case sensitive)table
- the table name (case sensitive)java.sql.SQLException
- on failurepublic static void dropAll(java.sql.Connection conn) throws java.sql.SQLException
conn
- the connectionjava.sql.SQLException
- on failurepublic static java.sql.ResultSet search(java.sql.Connection conn, java.lang.String text, int limit, int offset) throws java.sql.SQLException
conn
- the connectiontext
- the search querylimit
- the maximum number of rows or 0 for no limitoffset
- the offset or 0 for no offsetjava.sql.SQLException
- on failurepublic static java.sql.ResultSet searchData(java.sql.Connection conn, java.lang.String text, int limit, int offset) throws java.sql.SQLException
conn
- the connectiontext
- the search querylimit
- the maximum number of rows or 0 for no limitoffset
- the offset or 0 for no offsetjava.sql.SQLException
- on failurepublic static void setIgnoreList(java.sql.Connection conn, java.lang.String commaSeparatedList) throws java.sql.SQLException
conn
- the connectioncommaSeparatedList
- the listjava.sql.SQLException
- on failurepublic static void setWhitespaceChars(java.sql.Connection conn, java.lang.String whitespaceChars) throws java.sql.SQLException
conn
- the connectionwhitespaceChars
- the list of charactersjava.sql.SQLException
- on failureprotected static java.lang.String asString(java.lang.Object data, int type) throws java.sql.SQLException
data
- the objecttype
- the SQL typejava.sql.SQLException
- on failureprotected static SimpleResultSet createResultSet(boolean data)
data
- true if the result set should contain the primary key data as
an array.protected static java.lang.String[][] parseKey(java.sql.Connection conn, java.lang.String key)
conn
- the database connectionkey
- the primary key condition as a stringprotected static java.lang.String quoteSQL(java.lang.Object data, int type) throws java.sql.SQLException
data
- the objecttype
- the SQL typejava.sql.SQLException
- on failureprotected static void removeAllTriggers(java.sql.Connection conn, java.lang.String prefix) throws java.sql.SQLException
conn
- the database connectionprefix
- the prefixjava.sql.SQLException
- on failureprotected static void setColumns(int[] index, java.util.ArrayList<java.lang.String> keys, java.util.ArrayList<java.lang.String> columns) throws java.sql.SQLException
index
- the column indices (will be modified)keys
- the key listcolumns
- the column listjava.sql.SQLException
- on failureprotected static java.sql.ResultSet search(java.sql.Connection conn, java.lang.String text, int limit, int offset, boolean data) throws java.sql.SQLException
conn
- the database connectiontext
- the querylimit
- the limitoffset
- the offsetdata
- whether the raw data should be returnedjava.sql.SQLException
- on failureprotected static void addWords(org.h2.fulltext.FullTextSettings setting, java.util.Set<java.lang.String> set, java.io.Reader reader)
setting
- the fulltext settingsset
- the hash setreader
- the readerprotected static void addWords(org.h2.fulltext.FullTextSettings setting, java.util.Set<java.lang.String> set, java.lang.String text)
setting
- the fulltext settingsset
- the hash settext
- the textprotected static boolean hasChanged(java.lang.Object[] oldRow, java.lang.Object[] newRow, int[] indexColumns)
oldRow
- the old rownewRow
- the new rowindexColumns
- the indexed columnspublic static void closeAll()
protected static java.sql.SQLException throwException(java.lang.String message) throws java.sql.SQLException
message
- the messagejava.sql.SQLException
- the exception