Keyword searches

When the clue you specify contains more than one word, you can direct the search engine to treat each word as a separate entity. This type of search is called a keyword search. When the text search engine performs a keyword search, it returns a row whenever it encounters one or more of the words in your clue.

You specify a keyword search by setting the SEARCH_TYPE tuning parameter to WORD and passing it to the search engine as the second parameter of the Row() constructor. For example, the following query instructs the search engine to return any row that contains one or more occurrences of the keywords multimedia, document, or editor in the description column:
SELECT id, description FROM videos
    WHERE etx_contains (description,
    Row('multimedia document editor', 'SEARCH_TYPE = WORD'));
The following figure illustrates this example.
Figure 1: Example of keyword search

Shows the use of the SEARCH_TYPE tuning parameter for single words. The hitlist from the videos table is the rows that contain the single words: "multimedia," "document," and "editor."

The search did not return the row with ID 1003 because the word multimedia is misspelled and the text does not contain the other two words in the clue. Even though the word multimedia is misspelled in the row with ID 1004, the row is still returned because it contains the other two words in the clue, document and editor.

The search engine assigns the rows returned by a keyword search a document score. The document score is based on the number of keywords found in a document. For example, a document that contains two of three keywords is scored twice as high as a document that contains only one of the keywords.

If you do not specify the SEARCH_TYPE tuning parameter in the etx_contains() operator, the text search engine defaults to keyword search. This means that the following two searches are equivalent and are therefore often used interchangeably in this manual:
SELECT id, description FROM videos
    WHERE etx_contains (description, 
    Row('multimedia document editor'));

SELECT id, description FROM videos
    WHERE etx_contains (description, 
    Row('multimedia document editor', 'SEARCH_TYPE = WORD'));