Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.core.storage.sql.db
Class H2Fulltext

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.db.H2Fulltext

public class H2Fulltext
extends java.lang.Object

An optimized Lucene-based fulltext indexing trigger and search.

Author:
H2 Group, Florent Guillaume

Nested Class Summary
static class H2Fulltext.Trigger
          Trigger used to update the lucene index upon row change.
 
Method Summary
static void createIndex(java.sql.Connection conn, java.lang.String indexName, java.lang.String schema, java.lang.String table, java.lang.String columns, java.lang.String analyzer)
          Creates a fulltext index for a table and column list.
static void dropAll(java.sql.Connection conn)
          Drops all fulltext indexes from the database.
static void init(java.sql.Connection conn)
          Initializes fulltext search functionality for this database.
static void reindex(java.sql.Connection conn)
          Re-creates the fulltext index for this database.
static java.sql.ResultSet search(java.sql.Connection conn, java.lang.String indexName, java.lang.String text)
          Searches from the given full text index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init(java.sql.Connection conn)
                 throws java.sql.SQLException
Initializes fulltext search functionality for this database. This adds the following Java functions to the database: It also adds a schema NXFT 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 NXFT_INIT FOR
      "org.nuxeo.ecm.core.storage.sql.db.H2Fulltext.init";
  CALL NXFT_INIT();
 

Parameters:
conn -
Throws:
java.sql.SQLException

createIndex

public static void createIndex(java.sql.Connection conn,
                               java.lang.String indexName,
                               java.lang.String schema,
                               java.lang.String table,
                               java.lang.String columns,
                               java.lang.String analyzer)
                        throws java.sql.SQLException
Creates a fulltext index for a table and column list.

A table may have any number of indexes at a time, but the index name must be unique. If the index already exists, nothing is done, otherwise the index is created and populated from existing data.

Usually called through:

   CALL NXFT_CREATE_INDEX('indexname', 'myschema', 'mytable', ('col1', 'col2'), 'lucene.analyzer');
 

Parameters:
conn - the connection
indexName - the index name
schema - the schema name of the table
table - the table name
columns - the column list
analyzer - the Lucene fulltext analyzer class
Throws:
java.sql.SQLException

reindex

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

Throws:
java.sql.SQLException

dropAll

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

Throws:
java.sql.SQLException

search

public static java.sql.ResultSet search(java.sql.Connection conn,
                                        java.lang.String indexName,
                                        java.lang.String text)
                                 throws java.sql.SQLException
Searches from the given full text index. The returned result set has a single ID column which holds the keys for the matching rows.

Usually called through:

   SELECT * FROM NXFT_SEARCH(name, 'text');
 

Parameters:
conn - the connection
indexName - the index name
text - the search query
Returns:
the result set
Throws:
java.sql.SQLException

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.