Administration: Omnidex Indexing

Omnidex Text

Displaying Results

Proximity searches can qualify rows with large blocks of text using Phrase Searches, BEFORE Searches and NEAR Searches. Once the rows are qualified, the obvious next step is to display the results. This can be more difficult if the text is as long as an entire book, or some other large block of text.

Omnidex allows excerpts to be retrieved from large blocks of text to make viewing easier. These excerpts show the portions of the text that qualified the row, with the search terms highlighted.

Excerpts are retrieved using the $CONTEXT function. The $CONTEXT function works hand-in-hand with the $CONTAINS function. The $CONTAINS function is used to label a particular search, and the $CONTEXT function retrieves excerpts for that same label. This is needed before there may be other criteria in the SQL statement, and even multiple Proximity Searches against multiple columns and tables. Only one Proximity Search can feed these excerpts, necessitating the pairing of the $CONTAINS function and the $CONTEXT function.

$CONTEXT Function

The $CONTEXT function retrieves excerpts of a text field based on a paired $CONTAINS function. By default, a simple excerpt is displayed; however, options exist to allow embedding HTML tags to highlight the search terms for easy display in a web environment.

> select        TITLE,
>>              $context
>>  from        BOOKS
>>  where       $contains(CONTENT, 'missisipi', 'misspellings');
TITLE
-----------------------------------------------------------------------------
$CONTEXT(BOOKS.CONTENT)
-----------------------------------------------------------------------------
Around the World in Eighty Days
--- at Nauvoo, on the *Mississippi*, numbering twenty-five thousand ---
>> night it crossed the *Mississippi* at Davenport, and by ---

The Adventures of Tom Sawyer
--- a point where the *Mississippi* River was a trifle --- and saw the broad
>> *Mississippi* rolling by! ---
2 rows returned

Excerpts can be easily formatted for display using HTML, including assigning CSS classes as needed:

> select        TITLE,
>>              $context(255, 'STYLE=HTML CLASSES')
>>  from        BOOKS
>>  where       $contains(CONTENT, 'missisipi', 'misspellings');
TITLE
-----------------------------------------------------------------------------
$CONTEXT(BOOKS.CONTENT)
-----------------------------------------------------------------------------
Around the World in Eighty Days
--- at Nauvoo, on the <span class="odx_word">Mississippi</span>, numbering
>> twenty-five thousand --- night it crossed the <span
>> class="odx_word">Mississippi</span> at Davenport, and by ---
The Adventures of Tom Sawyer
--- a point where the <span class="odx_word">Mississippi</span> River was a
>> trifle --- and saw the broad <span class="odx_word">Mississippi</span>
>> rolling by! ---
2 rows returned

If the statement contains multiple $CONTAINS functions, they should be labelled with distinct names, and the $CONTEXT should reference the appropriate $CONTAINS clause. The excerpts will be created based on that column's criteria.

> select        TITLE,
>>              $CONTEXT(255, 'STYLE=TEXT', 'CONTENT')
>>  from        BOOKS
>>  where       $contains(LANGUAGE, 'English',, 'LANGUAGE') and
>>              $contains(CONTENT, 'missisipi', 'misspellings', 'CONTENT');

TITLE
-----------------------------------------------------------------------------
$CONTEXT(BOOKS.CONTENT)
-----------------------------------------------------------------------------
Around the World in Eighty Days
--- at Nauvoo, on the *Mississippi*, numbering twenty-five thousand ---
>> night it crossed the *Mississippi* at Davenport, and by ---
The Adventures of Tom Sawyer
--- a point where the *Mississippi* River was a trifle --- and saw the broad
>> *Mississippi* rolling by! ---
2 rows returned
>

Additional Resources

See also:

 
Back to top
admin/indexing/text/results.txt ยท Last modified: 2016/06/28 22:38 (external edit)