Query Relaxation
The query relaxation feature enables your application to execute the most restrictive version of a query first and progressively relax the query until the required number of hits are obtained.
For example, your application searches first on green pen and then the query is relaxed to green NEAR pen to obtain more hits.
The following query template defines a query relaxation sequence. The query of green pen is entered in sequence.
{green} {pen}
{green} NEAR {pen}
{green} AND {pen}
{green} ACCUM {pen}
The following is the query relaxation template for these transformations:
select id from docs where CONTAINS (text,
'<query>
<textquery lang="ENGLISH" grammar="CONTEXT">
<progression>
<seq>{green} {pen}</seq>
<seq>{green} NEAR {pen}</seq>
<seq>{green} AND {pen}</seq>
<seq>{green} ACCUM {pen}</seq>
</progression>
</textquery>
<score datatype="INTEGER" algorithm="COUNT"/>
</query>')>0;
Query hits are returned in this sequence with no duplication as long as the application needs results.
Query relaxation is most effective when your application needs the top-N hits to a query, which you can obtain with the DOMAIN_INDEX_SORT hint or in a PL/SQL cursor.
Using query templating to relax a query is more efficient than reexecuting a query.