Perform Boolean searches

You perform a Boolean search when you use any Boolean expression in a text search.

For example, to search for text in the description column that contains the words multimedia and editor but not the word video, execute the following SQL statement:
SELECT id, description FROM videos
    WHERE etx_contains (description, 
    Row('multimedia & editor & !video', 
    'SEARCH_TYPE = BOOLEAN_SEARCH'));
In this example, the & symbol represents a logical AND operator. You can also use the | symbol to represent a logical OR and the ! or ^ symbols to represent the logical NOT. The following figure displays the qualifying rows, also called a hitlist, when the query in the example is run on the videos table.
Figure 1: Sample text search query that uses a Boolean expression

Shows a Boolean search for rows that contain the keywords "multimedia" and "editor" but not the keyword "video" from a table whose column has various spellings for "multimedia" and one row that has both "multimedia" and "video." The hitlist is two returned rows that contain "multimedia."

You can use the third, optional argument of the etx_contains() operator to pass an SLV to the search engine. The search engine uses this variable to record the document score it assigns to each row in the hitlist and to record highlighting information. The data type of the SLV is etx_ReturnType, a row type derived from HCL OneDB™ that consists of two fields that together contain the scoring and highlighting information.

For more information about using the scoring information of the SLV, see Document scoring for fuzzy searches. For more general information about SLVs, see the HCL OneDB Guide to SQL: Syntax.

For more information about the etx_ReturnType data type, its two fields, and how to use the information contained in the fields, see The etx_ReturnType data type.

For an overview of the types of searches you can execute with the , see Concepts.

The following figure provides a summary of the etx_contains() syntax used thus far.
Figure 2: Summary of etx_contains() syntax

Shows an example of a CREATE INDEX statement to create an etx index and a SELECT statement that searches text in the indexed column.