You can use the procedure CTX_QUERY.STORE_SQE
to store the definition of a query without storing any results. Referencing the query with the CONTAINS
SQL operator references the definition of the query. In this way, stored query expressions make it easy for defining long or frequently used query expressions.
Stored query expressions are not attached to an index. When you call CTX_QUERY.STORE_SQE
, you specify only the name of the stored query expression and the query expression.
The query definitions are stored in the Text data dictionary. Any user can reference a stored query expression.
Oracle Text Reference to learn more about the syntax of CTX_QUERY.STORE_SQE
The following example creates a stored query expression called disaster that searches for documents containing the words tornado, hurricane, or earthquake:
begin ctx_query.store_sqe('disaster', 'tornado | hurricane | earthquake'); end;
To execute this query in an expression, write your query as follows:
SELECT SCORE(1), title from news WHERE CONTAINS(text, 'SQE(disaster)', 1) > 0 ORDER BY SCORE(1);
Oracle Text Reference to learn more about the syntax of CTX_QUERY.STORE_SQE