highlighting terms in document using ctx_doc.highlight procedure
doing an example from Oracle Text Application Guide, i decided to build an
application that first retrieves the list of documents satisfying the user query,
satisfying the word search. then the user may wish to view the documents
with the terms in the document being highlighted.
so , i created a procedure:
PROCEDURE "STARDOC"."SEARCHHIGHLIGHT" (
"DOC_ID" IN varchar2,"QUERY" IN VARCHAR2) IS
v_clob_selected clob default empty_clob();
BEGIN -- executable part starts here
ctx_doc.markup (index_name =>'idxdocuments',
textkey => doc_id,
text_query => query,
restab => v_clob_selected,
starttag => '<i><font color=red>',
endtag => '</font></i>');
INSERT INTO searchviewhtml VALUES (1, v_clob_selected);
-- EXCEPTION -- exception-handling part starts here
-- WHEN comm_missing THEN
-- dbms_output.put_line('Commision is NULL');
i didn't understand the parameter to the procedure text_query. should i pass
the exact query that was used to list the documents according to user criteria.
also in the text_key parameter, should i pass the primary key of the table containing documents.
it is not clear because i used a number as the primary key whereas the 'textkey'
parameter is a varchar data type.
Message was edited by:
For the text_query parameter, use the same thing that you put in a contains query, like 'word1 and word2' or whatever words you searched for, not the whole select statement. For the textkey parmeter, you can use either the primary key or the rowid, depending on how ctx_doc.set_key_type is set. If you search this forum, I have posted a few ctx_doc.markup examples.
SP2-0734: unknown command beginning "ctx_doc.se..." - rest of line ignored.
in the parameter should i pass the column name of the documents table or what... iam not clear. also the following error was returned. please help!
You need to either enter as I demonstrated, with a begin and end, or use execute, like so:
SQL> EXECUTE ctx_doc.set_key_type('PRIMARY_KEY')
SQL> EXECUTE ctx_doc.set_key_type('ROWID')
as you would with any other packaged procedure. The words 'PRIMARY_KEY' and 'ROWID' are the actual parameter values. You do not pass a column name.