Use full text indexing functions to search for specific words in a given column in SELECT, INSERT, UPDATE, or DELETE queries. The word search is controlled by the text indexing parameters for the table in which the column resides. DBISAM's SQL supports the following word search functions:

 

FunctionDescription

TEXTSEARCHPerforms an optimized text word search on a field, if the field is part of the full text index for the table, or a brute-force text word search if not.
 
TEXTOCCURSCounts the number of times a list of words appears in a field based upon the full text indexing parameters for the table.

 

 

TEXTSEARCH Function

 

The TEXTSEARCH function searches a column for a given set of words in a search string constant. The syntax is as follows:

TEXTSEARCH(search string constant
          IN column_reference)
TEXTSEARCH(search string constant,
          column_reference)

The optimization of the TEXTSEARCH function is controlled by whether the column being searched is part of the full text index for the table in which the column resides. If the column is not part of the full text index then the search will resort to a brute-force scan of the contents of the column in every record that satisfies any prior conditions in the WHERE clause. Also, the parsing of the list of words in the search string constant is controlled by the text indexing parameters for the table in which the column being searched resides.

 

In the following example, the words 'DATABASE QUERY SPEED' are searched for in the TextBody column:

SELECT GroupNo, No
FROM article
WHERE TEXTSEARCH('DATABASE QUERY SPEED' IN TextBody)

TEXTSEARCH returns a boolean value indicating whether the list of words exists in the column for a given record. TEXTSEARCH can only be used with string or memo columns.

 

TEXTOCCURS Function

 

The TEXTOCCURS function searches a column for a given set of words in a search string constant and returns the number of times the words occur in the column. The syntax is as follows:

TEXTOCCURS(search string constant
          IN column_reference)
TEXTOCCURS(search string constant,
          column_reference)

TEXTOCCURS is always a brute-force operation and accesses the actual column contents to perform its functionality, unlike the TEXTSEARCH function which can be optimized by adding the column being searched to the full text index for the table. Also, the parsing of the list of words in the search string constant is controlled by the text indexing parameters for the table in which the column being searched resides.

 

In the following example, the number of occurrences of the words 'DATABASE QUERY SPEED' in the TextBody column are used to order the results of a TEXTSEARCH query in order to provide ranking for the text search:

SELECT GroupNo, No,
TEXTOCCURS('DATABASE QUERY SPEED' IN TextBody) AS NumOccurs
FROM article
WHERE TEXTSEARCH('DATABASE QUERY SPEED' IN TextBody)
ORDER BY 3 DESC

TEXTOCCURS returns an integer value indicating the total number of times the list of words occurs in the column for a given record.  TEXTOCCURS can only be used with string or memo columns.