Use the db2ext.highlight function to get information about why a document qualified as a search result. More specifically, it can be used to:
Note that the db2ext.highlight function can only be used with the db2ext.textsearch table-valued function. The table-valued function searches the index providing the results for the HIGHLIGHT function to use.
For information on using the db2ext.textsearch function, see DB2EXT.TEXTSEARCH.
>>-db2ext.highlight---------------------------------------------> >--(--document-content--,--hit-information--,--hit-processing-information--)-><
The following are input parameters:
If this option is omitted, 0 is taken as the default and the entire document containing start and end tags (if specified) is returned. In this case, the WINDOW_SIZE option is ignored.
The following are return parameters.
The following example shows how you can use the HIGHLIGHT function:
select p.id, p.title, db2ext.highlight(p.content, t.hitinformation, 'TAGS = ("<bf>", "</bf>"), WINDOW_NUMBER = 5, WINDOW_SIZE = 200, WINDOW_SEPARATOR = "...", FORMAT = "XML", SECTIONS = ("section1-name", "section2-name")') FROM patent p, table (db2ext.textsearch( '"relational database systems"', 'DB2EXT', 'TI_FOR_CONTENT', 0, 20, CAST(NULL as BIGINT), 15)) t WHERE p.id = t.primkey
Using documents larger than 100 KB will cause the SQL query to terminate and produce an SQL error (SQL 1476N and sql error -433). To avoid this, use the db2exthl command to increase the document content size. For information, see DB2EXTHL (utility).
Special characters, such as "newline" will be returned as is.