$CONTEXT
The $CONTEXT function is a select list item that retrieves excerpts,
or windows, from a document showing the context in which a row matched
the qualification criteria from a $CONTAINS criteria predicate. It shows
the context in which the search criteria occurred in the document, without
the cost of trafficking the entire document. Snippets of the original
text, including the keywords and words around it, are returned to the
application.
This can prove useful in two ways. First, it allows a distillation of
the row to be retrieved without incurring the cost of trafficking large
amounts of data. This can make a tremendous difference in the application
performance. Second, it provides a concise and convenient method of communicating
the essence of the row to the user. A large amount of content is difficult
for a user to absorb, but excerpts from a document can be quickly understood.
$CONTEXT is used in conjunction with $CONTAINS,
meaning the search criteria MUST be stated in a $CONTAINS function in
a WHERE clause predicate. Additionally, a matching label must be specified
in both the $CONTEXT and $CONTAINS functions, when the SQL statement contains
multiple $CONTAINS criteria predicates.
Syntax
$CONTEXT[(length[, 'options'[, 'label']])]
length
Optional. Specifies the length of the output string. Default 256 bytes.
options
Optional. See Options (below) for a list of valid
options. The entire options string must be enclosed in single quotes.
label
Optional UNLESS the SQL statement has multiple $CONTAINS functions. The
label distinguishes between multiple $CONTAINS functions in a single SELECT
statement. This label is case-insensitive and may be up to 32 characters
in length. The label must be enclosed in single quotes.
Options
The entire options string must be enclosed inside single quotes. 'options
list'.
Multiple options can be passed, space separated with the entire options
list enclosed in single quotes.
If, however, the value argument of any option=value pair contains any
spaces, the value portion must be enclosed in escaped single quotes, as
follows: 'style=html highlight=\'<span onclick="runFunc();">\''
MAXCONTENTS=n
Limit the number of context excerpts to n.
STYLE=
Render the result in the following style:
TEXT (default)
HTML - Causes the keywords to be enclosed in <strong></strong>
html tags.
> select $context(500,'style=html','lbl1') from news
where $contains(article,'baseball',,'lbl1')
--- I made an entire <strong>baseball</strong> season's worth
of reservati...
--- by a meeting with <strong>baseball</strong> star Sammy
Sosa and ---
FORMAT=
Render the result using the following format:
COMPRESSED (default)
UNCOMPRESSED - Expands the window size, showing
the entire column text up to n bytes as specified in the length parameter,
instead of just a snippet. Note that the keywords may not occur within
the first n bytes.
> select $context(500,'format=uncompressed','lbl1')
from news where $contains(article,'baseball',,'lbl1')
A terrific Roz Chast cartoon in last week's New Yorker magazine posits
the...
The courtship of Tracy McGrady began with the Orlando Magic sending a
whit...
COLLEGESGeorge Washington -- Freshman Kristen Fagley named Atlantic 10
Con...
A terrific Roz Chast cartoon in last week's New Yorker magazine posits
the...
PRESERVE_FORMAT=
Control whether tabs, linefeeds and other formatting characters are preserved
in the output.
Set ON (default when FORMAT=UNCOMPRESSED)
or OFF (default when FORMAT=COMPRESSED)
HIGHLIGHT="string"
HTML tag to use to highlight keywords when STYLE=HTML. Defaults to "<strong>".
> select $context(500,'style=html highlight=<em>','lbl1')
from news where $contains(article,'baseball',,'lbl1')
--- I made an entire <em>baseball</em> season's worth of reservati...
--- by a meeting with <em>baseball</em> star Sammy Sosa and
---
At
this time, embedded single quotes are not supported in the highlight string.
Embedded double quotes are supported. Therefore, a highlight string like
\'<span onclick="runFunc('parameter');">\' is not
supported. However, '\<span onclick="runFunc();">\'
is supported.
END_HIGHLIGHT="string"
HTML tag to use to end the highlighting of keywords when STYLE=HTML. Defaults
to the HIGHLIGHT string setting with an initial backslash, such as "</strong>".
This option is only necessary with more complex HIGHLIGHT strings.
> select $context(500,'style=html highlight=\'<span
class="myclass">\' end_highlight=</span>','lbl1') from
news where $contains(article,'baseball',,'lbl1')
--- I made an entire <strong>baseball</strong> season's worth
of reservati...
--- by a meeting with <strong>baseball</strong> star Sammy
Sosa and ---
CLASSES
Enclose keywords in CSS classes. The class name is predefined, odx_content_word.
The class definition can be customized as needed for the application.
> select $context(1500,'style=html classes','lbl1')
from news where $contains(article,'baseball',,'lbl1')
--- I made an entire <span class="odx_context_word">baseball</span>
season...
--- by a meeting with <span class="odx_context_word">baseball</span>
star ...
COLLEGESGeorge Washington -- Freshman Kristen Fagley named Atlantic 10
Con...
Example
SELECT title, $score, $context FROM books
WHERE $contains(content, 'white rabbit', 'synonyms')
ORDER BY $score
Alice's Adventures in Wonderland
79.050003
--- daisies, when suddenly a White Rabbit with pink eyes ran --- It was
the
>> White Rabbit returning, splendidly dressed, with --- Bill It
was the
>> White Rabbit, trotting slowly back again, ---
The Adventures of Huckleberry Finn
29.570000
--- de on'y white genlman dat ever...the spunk of a rabbit. --- Is your
man
>> white or black?" I...the spunk of a rabbit. --- the spunk
of a rabbit.
>> I see I...up and says: "He's white." ---
Webster's Revised Unabridged Dictionary (1913)
18.160000
--- a yellow disk and white or pinkish...ashkoko, dassy, and rock rabbit.
>> --- ashkoko, dassy, and rock rabbit. See Cony, and...brocade.
Dambonite
>> (n.) A white, crystalline, sugary substance obtained ---
The Taming of the Shrew
2.860000
--- parsley to stuff a rabbit; and so may...gentlewoman? Such war of white
>> and red within her ---
Webster's Revised Unabridged Dictionary (1913)
18.160000
--- a yellow disk and white or pinkish...ashkoko, dassy, and rock rabbit.
>> --- ashkoko, dassy, and rock rabbit. See Cony, and...brocade.
Dambonite
>> (n.) A white, crystalline, sugary substance obtained ---
The Taming of the Shrew
2.860000
--- parsley to stuff a rabbit; and so may...gentlewoman? Such war of white
>> and red within her ---
The Adventures of Tom Sawyer
2.860000
--- a hunted and helpless rabbit look as she...her face--it was white
with
>> terror] --"did you ---
Top
|