This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
admin:indexing:text:results [2012/01/31 21:10] doc created |
admin:indexing:text:results [2016/06/28 22:38] (current) |
||
|---|---|---|---|
| Line 10: | Line 10: | ||
| [[admin:indexing:text:retrieve|External Files]] | | [[admin:indexing:text:retrieve|External Files]] | | ||
| [[admin:indexing:text:proximity|Proximity Searches]] | | [[admin:indexing:text:proximity|Proximity Searches]] | | ||
| + | [[admin:indexing:text:advanced|Advanced Searches]] | | ||
| **[[admin:indexing:text:results|Displaying Results]]** | | **[[admin:indexing:text:results|Displaying Results]]** | | ||
| [[admin:indexing:text:relevancy|Relevancy]] | [[admin:indexing:text:relevancy|Relevancy]] | ||
| Line 17: | Line 18: | ||
| ==== Displaying Results ==== | ==== Displaying Results ==== | ||
| - | FullText Indexes are a specialized index designed for large blocks of text, such as abstracts, articles, and text documents. FullText Indexes parse the contents of the column so that each word is indexed separately. FullText Indexes also track the position of each word in the field to aid in providing relevancy scores. Queries can use special syntax to require that one word be a certain distance from another word, or adjacent as a phrase. FullText Indexes necessarily have more overhead than QuickText Indexes. | + | 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. |
| - | Searches that evaluate the distance between one word and another are called Proximity Searches. Proximity Searches have an extended syntax, with special operators. Note that Proximity Searches are only possible against columns that are indexed using FullText indexes. | + | 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. |
| - | There are three basic categories of Proximity Searches: | + | 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. |
| - | === Phrase Searches === | + | === $CONTEXT Function === |
| - | A phrase search finds occurrences of between two and eight words adjacent to each other in the column. To specify phrases in the search criteria, enclose the phrase in double quotation marks. The following example searches for the phrase "No place like home" in the sample BOOKS database, finding the Wizard of Oz. | + | The [[dev:sql:functions:context|$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. |
| <code> | <code> | ||
| - | > select title from books where content = '"no place like home"'; | + | > select TITLE, |
| + | >> $context | ||
| + | >> from BOOKS | ||
| + | >> where $contains(CONTENT, 'missisipi', 'misspellings'); | ||
| TITLE | TITLE | ||
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ||
| - | The Wonderful Wizard of Oz | + | $CONTEXT(BOOKS.CONTENT) |
| - | </code> | + | |
| - | + | ||
| - | + | ||
| - | === BEFORE Searches === | + | |
| - | + | ||
| - | A BEFORE search is an expansion on a Phrase Search. The BEFORE operator used in qualification criteria allows more control over how many words are allowed between two keywords. In fact, a Phrase Search is simply a special implementation of a BEFORE search. | + | |
| - | + | ||
| - | The BEFORE operator is used between two words, as in "word1 BEFORE(n) word2". The BEFORE operator accepts an optional parameter containing a value between 1 and 999, representing the number of words by which //word1// may precede //word2//. If no value is provided, the default value of 10 is used. The Phrase Search example above could also be submitted as: //no// BEFORE //place// BEFORE //like// BEFORE //home//, or //no// BEFORE(1) //place// BEFORE(1) //like// BEFORE(1) //home//. | + | |
| - | + | ||
| - | The following example searches for the word //place// within 25 words before the word //home//. Note that the use of operators within SQL criteria requires that the criteria be enclosed in parentheses, indicating that the criteria is really an expression with special operators, rather than a literal string. | + | |
| - | + | ||
| - | <code> | + | |
| - | > select title from books where content = '(place before(25) home)'; | + | |
| - | + | ||
| - | TITLE | + | |
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ||
| Around the World in Eighty Days | Around the World in Eighty Days | ||
| - | The Wonderful Wizard of Oz | + | --- 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 | ||
| </code> | </code> | ||
| - | This example immediate raises the question of how to see the locations in the book where this criteria is met, and also how to sort the results based on relevancy. The [[admin:indexing:text:results|next two pages]] of this section describe functions that can be used to meet these requirements. | + | Excerpts can be easily formatted for display using HTML, including assigning CSS classes as needed: |
| - | + | ||
| - | === NEAR Searches === | + | |
| - | + | ||
| - | A NEAR search is nearly the same as a BEFORE search, except that the words can be in any relative order to each other. The NEAR operator is used between two words, as in "word1 NEAR(n) word2". The NEAR operator accepts an optional parameter containing a value between 1 and 999, representing the number of words by which //word1// may precede or follow //word2//. If no value is provided, the default value of 10 is used. | + | |
| - | + | ||
| - | The following example searches for the word //home// within 25 words near the word //place//. The words may be in any order relative to each other. | + | |
| <code> | <code> | ||
| - | > select title from books where content = '(place near(25) home)'; | + | > select TITLE, |
| + | >> $context(255, 'STYLE=HTML CLASSES') | ||
| + | >> from BOOKS | ||
| + | >> where $contains(CONTENT, 'missisipi', 'misspellings'); | ||
| TITLE | TITLE | ||
| + | ----------------------------------------------------------------------------- | ||
| + | $CONTEXT(BOOKS.CONTENT) | ||
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ||
| Around the World in Eighty Days | 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 | The Adventures of Tom Sawyer | ||
| - | The Wonderful Wizard of Oz | + | --- 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 | ||
| </code> | </code> | ||
| - | === Default Proximity Search === | + | 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. |
| - | + | ||
| - | Any search against a FullText index is inherently a Proximity Search. Specifically, the NEAR(999) operator is used whenever there is no other operator before words. This means that the following two examples are synonymous: | + | |
| <code> | <code> | ||
| - | > select title from books where content = 'place home'; | + | > select TITLE, |
| + | >> $CONTEXT(255, 'STYLE=TEXT', 'CONTENT') | ||
| + | >> from BOOKS | ||
| + | >> where $contains(LANGUAGE, 'English',, 'LANGUAGE') and | ||
| + | >> $contains(CONTENT, 'missisipi', 'misspellings', 'CONTENT'); | ||
| TITLE | TITLE | ||
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ||
| - | Alice's Adventures in Wonderland | + | $CONTEXT(BOOKS.CONTENT) |
| - | Around the World in Eighty Days | + | |
| - | Hamlet | + | |
| - | The Adventures of Tom Sawyer | + | |
| - | The Wonderful Wizard of Oz | + | |
| - | + | ||
| - | > select title from books where content = '(place NEAR(999) home)'; | + | |
| - | + | ||
| - | TITLE | + | |
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ||
| - | Alice's Adventures in Wonderland | ||
| Around the World in Eighty Days | Around the World in Eighty Days | ||
| - | Hamlet | + | --- at Nauvoo, on the *Mississippi*, numbering twenty-five thousand --- |
| + | >> night it crossed the *Mississippi* at Davenport, and by --- | ||
| The Adventures of Tom Sawyer | The Adventures of Tom Sawyer | ||
| - | The Wonderful Wizard of Oz | + | --- a point where the *Mississippi* River was a trifle --- and saw the broad |
| + | >> *Mississippi* rolling by! --- | ||
| + | 2 rows returned | ||
| + | > | ||
| </code> | </code> | ||
| - | |||
| - | === Proximity Search Limitations === | ||
| - | There are some limitations to Proximity Searches. Columns indexed with the Proximity option are limited to 4 million keywords. The Proximity option cannot be used on pre-joined indexes. Lastly, Proximity Searches only pay attention to word proximity, and not to semantics, sentence structure or context. | ||
| - | |||
| ===== ===== | ===== ===== | ||
| - | **[[admin:indexing:text:proximity|Prev]]** | | + | **[[admin:indexing:text:advanced|Prev]]** | |
| **[[admin:indexing:text:relevancy|Next]]** | **[[admin:indexing:text:relevancy|Next]]** | ||