Querying an index

To query an index, use the table function created by CREATEINDEX.

The table function created by CREATEINDEX has the following shape:

$SCHEMANAME.$TABLENAME__TEXTCOL
(
    QUERY VARCHAR( 32672 ),
    WINDOWSIZE INT,
    SCORECEILING REAL
)
RETURNS TABLE
(
    $keyColumn1 $keyColumn1datatype,
    ...
    $keyColumnN $keyColumnNdatatype,
    DOCUMENTID INT,
    SCORE REAL
)

The arguments have the following meaning:

Remember that when the index was created, the application specified how the query should be parsed.

In the returned result set, the key columns join back to the original table or view, and they identify which row of that table/view holds the scored text. The other columns in the returned result set have the following meanings:

Derby uses the same analyzer to query the index that was last used to create or update the index.

Example

-- Selects the primary key and score for the best 3 matches for
-- the text.
select presidentID, speechID, score
from table
(
    us.presidentsSpeeches__speechText
    (
        'When in the course of human events',
        3,
        null
    )
) t;

-- The last row in the previous result had score 1.0.
-- This selects the primary key and score for the next 4 matches for the
-- text.
select presidentID, speechID, score
from table
(
    us.presidentsSpeeches__speechText
    (
        'When in the course of human events',
        4,
        1.0
    )
) t;
Related reference
Creating an index
Updating an index
Dropping an index
Listing indexes
Running the luceneSupport tool with a security manager