Fulltext_get_context

SQL

function Fulltext_get_context(IN ft_label CHAR(52), IN doc BLOB, IN format CHAR(10), IN mode INT, IN position INT,IN cnt INT, IN margin INT, IN decoration CHAR(50)); returns CLOB;


Parameters

ft_label
fulltext system label
doc
document or document reference
format
document format (TXT, TEXT or PLAIN for plain text, RTF, DOC or HTML etc. for other defined documents) or empty string
mode
mode of document passing
position
position (of word) in a document, around which the context is searched for
cnt
count of marked words
margin
number of words before and after position in context
decoration
character, that will encase cnt words in the position position in the result context


Since version

9.5

Description

The function returns the context (neighboring text) of a word occurrence (or a multiword phrase) found with the Fulltext predicate.

The searched document may be passed in the modes. The mode parameter specifies the option you choose:

valuedescription
0 the document is in the doc parameter contents (text or binary)
1 the document in in the file, whose name is in the doc parameter

The format parameter allows you to specify the format of texts to index. If you know the format in advance (e.g. when indexing CLOBs in a table), use the abbreviation for the format (e.g. TXT), if you don't know it (e.g. when indexing file contents in a folder), use empty string - an analysis of the beginning fragment of the texts will be done and corresponding converter will be used for known formats. If the analysis fails, an error will occur.

The word (phrase) position in the document may be set with the @@FULLTEXT_POSITION system variable, which is assigned value each time the Fulltext predicate returning TRUE is evaluated. If you're searching for a multiword phrase, the position points to the first word of the phrase.

The margin specifies how many words before and after the found word (phrase) will be returned (along with the word and the character set in decoration) as the function result. You must specify the word count in the phrase in the cnt parameter.

The decoration parameter allows you to emphasize the searched word in the context. The string parameter must have the following form : character_before%characters_after, where % is the position of the searched word (phrase). If the function result is passed to a browser as HTML, it may be helpful to use this notation: "<B>%</B>"



Returns

Returns the context of an occurrence of the specified word of the size 2*margin+cnt words.



Example

SELECT Fulltext_get_context(".ftx_test",doc,"TXT",0,@@FULLTEXT_POSITION,1,5,">>%<<")
FROM Doctab
WHERE Fulltext(".ftx_test",id,"Database")

The same example in a procedure using a cursor:

DECLARE temp CLOB;
FOR row AS ftcur INSENSITIVE CURSOR FOR
  SELECT id,doc,@@FULLTEXT_POSITION AS pos
  FROM Doctab
  WHERE Fulltext(".ftx_test",id,"Database")
DO
  SET temp = Fulltext_get_context(".ftx_test",row.doc,"TXT",0,row.pos,1,5,">>%<<");
  CALL log_write(temp);
END FOR;