Why are the two last rewrite rules in the example from Oracle documentation not working?
Source http://docs.oracle.com/cd/B28359_01/text.111/b28303/query.htm#i1007557
Query applications sometimes parse end user queries, interpreting a
query string in one or more ways using different operator
combinations. For example, if a user enters a query of kukui nut, your
application might enter the queries {kukui nut} and {kukui or nut} to
increase recall.The query rewrite feature enables you to submit a single query that
expands the original query into the rewritten versions. The results
are returned with no duplication.You specify your rewrite sequences with the query template feature.
The rewritten versions of the query are executed efficiently with a
single call to CONTAINS or CATSEARCH.The following template defines a query rewrite sequence. The query of
{kukui nut} is rewritten as follows:{kukui} {nut}
{kukui} ; {nut}
{kukui} AND {nut}
{kukui} ACCUM {nut}
The query rewrite template for these transformations is as follows:
select id from docs where CONTAINS (text, '<query> <textquery lang="ENGLISH" grammar="CONTEXT"> kukui nut <progression> <seq><rewrite>transform((TOKENS, "{", "}", " "))</rewrite></seq> <seq><rewrite>transform((TOKENS, "{", "}", " ; "))</rewrite></seq> <seq><rewrite>transform((TOKENS, "{", "}", "AND"))</rewrite></seq> <seq><rewrite>transform((TOKENS, "{", "}", "ACCUM"))</rewrite></seq> </progression> </textquery> <score datatype="INTEGER" algorithm="COUNT"/> </query>')>0;
There’s an error in the example provided by Oracle. It is essential that the query operators are separated with spaces:
so ” AND ” and ” ACCUM ” instead of “AND” and “ACCUM” as in the documentation.