This is an old revision of the document!
Overview | Textual Datatypes | External Files | Proximity Searches | Advanced Searches | Displaying Results | Relevancy
When searching large blocks of text, relevancy becomes more important. If the criteria occurs many times in a large block of text, it can be considered more relevant than if the criteria occurs only once. When multiple words are nearer to each other, or occur nearer to the beginning of the block of text, it can be considered more relevant. Omnidex provides a $SCORE function that provides relevancy scores based on these considerations. Rows can be filtered or ordered based on relevancy scores so that the most valuable blocks of text are shown first.
The $SCORE function retrieves excerpts of a text field based on a paired $CONTAINS function. The score is a number between 1 and 100, with 100 representing the highest relevancy. Note that the $SCORE function only returns a relevancy score when paired with a $CONTAINS function; otherwise, it will always return a score of 100.
> select $score, >> TITLE, >> $context >> from BOOKS >> where $contains(CONTENT, '(place near(25) home)'); $SCORE -------------------------------- TITLE ----------------------------------------------------------------------------- $CONTEXT(BOOKS.CONTENT) ----------------------------------------------------------------------------- 49.410000 The Wonderful Wizard of Oz --- There is no *place* like *home*." --- 37.210000 The Adventures of Tom Sawyer --- I want to go *home*." "But, Joe, there ain't such another >> swimming-*place* anywhere." --- 36.400000 Around the World in Eighty Days --- travelled nor stayed from *home* overnight, he felt...this would be the >> *place* he was after. --- which was to take *place* the next...found him >> not at *home*. --- 3 rows returned
If the statement contains multiple $CONTAINS functions, they should be labelled with distinct names, and the $SCORE function should reference the appropriate $CONTAINS label. The relevancy score will be created based on that column's criteria.
> select $score(, 'CONTENT') RELEVANCY, >> TITLE, >> $context(255, 'STYLE=TEXT', 'CONTENT') >> from BOOKS >> where $contains(LANGUAGE, 'English',, 'LANGUAGE') and >> $contains(CONTENT, 'magic',, 'CONTENT') >> order by RELEVANCY desc; RELEVANCY -------------------------------- TITLE ----------------------------------------------------------------------------- $CONTEXT(BOOKS.CONTENT) ----------------------------------------------------------------------------- 83.350000 The Wonderful Wizard of Oz --- The *Magic* Art of the Great --- will use all the *magic* arts I know of >> --- me to use my *magic* power to send you --- and then by her *magic* >> arts made the iron --- 56.380000 Around the World in Eighty Days --- transferred by some strange *magic* to the antipodes. --- interest, as >> if by *magic*; --- 52.360000 Alice's Adventures in Wonderland --- for Alice, the little *magic* bottle had now had --- 52.360000 Hamlet --- thrice infected, Thy natural *magic* and dire property, On --- 4 rows returned
See also: