49.2 QUERY_SEARCH_ENGINE Function

This function converts a simple end-user search query into the corresponding Oracle Text syntax for a smart search that incorporates query relaxation.

It executes the most restrictive version of a query first (such as exact match search), then progressively relaxes the query using less restrictive queries (such as stem search and fuzzy matching).

While maximizing the number of results, this function ensures that the most exact and relevant matches have a higher score.

Syntax

APEX_SEARCH.QUERY_SEARCH_ENGINE (
    p_search_expression IN VARCHAR2 )
    RETURN CLOB;

Parameters

Parameter Description
p_search_expression End-user search query to convert to Oracle Text syntax.

Returns

This function returns the generated Oracle Text query based on the provided search expression.

Example

select query_search_engine('red shorts') from dual;

TEXT_QUERY
----------------------------------------
<query>
   <textquery>
   <progression>
   <seq>{red} {shorts}</seq>
   <seq>${red} ${shorts}</seq>
   <seq>FUZZY({red},40,1000,W) FUZZY({shorts},40,1000,W)</seq>
   <seq>{red} AND {shorts}</seq>
   <seq>${red} AND ${shorts}</seq>
   <seq>FUZZY({red},40,1000,W) AND FUZZY({shorts},40,1000,W)</seq>
   <seq>{red} ACCUM {shorts}</seq>
   <seq>${red} ACCUM ${shorts}</seq>
   <seq>FUZZY({red},40,1000,W) ACCUM FUZZY({shorts},40,1000,W)</seq>
   </progression>
   </textquery>
</query>