I am querying an Oracle 10g database. The database contains a table with documents that has an oracle text index. I query the database using a query like
SELECT SCORE(1), title from news WHERE CONTAINS(text, 'people OR country ', 1) > 0;
Is there a way to see what terms in the "contains" statement that Oracle found in the documents?
Best Answer
You might want to look into the
MARKUP
orHIGHLIGHT
functions of theCTX_DOC
package. An example of howMARKUP
can be used for your query (this assumes your index is calledidx_news
and you have anID
column):What it does is mark up your text (surround the found items with
<<<>>>
) and outputs that new text to aclob
which is then searched for the markup. All text that is found in your query will be marked up but my PL/SQL will only display the first result; it can be adapted to find them all and display only the unique ones. This is a simple example and perhaps can become too complicated for your original query but it's here to point the way.Alternatively, a simple
SELECT
may suffice if all you have is anOR
in your text query:This checks the score for individual searches on 'people' and 'country' and works out which ones were positive, returning 'both' if both search terms were found.