Retrieving Textual Metadata

Many textual applications have flexible and intuitive user interfaces that assist users in assembling queries. A common example is an application that checks the user’s criteria for spelling errors. Alternatively, if a query does not return any results, the application may suggest alternate queries that appear somewhat similar. These applications require an ability to retrieve textual metadata. Textual metadata refers to items such as definitions for a word or phrase, suggestions for alternate words or phrases, and the expanded searches for features like synonyms, misspellings and forms.

Omnidex provides a $LOOKUP function to retrieve textual metadata. Similarly, the ODXSQL utility provides a LOOKUP command to retrieve the same information. The $LOOKUP function is usually use to retrieve the textual metadata for a particular $CONTAINS function. For this reason, the first three parameters of the $LOOKUP function match the $CONTAINS function. With very few exceptions, the parameters of the $CONTAINS function can simply be placed in a $LOOKUP function. In addition, the $LOOKUP function can also be used to retrieve dictionary definitions and spelling suggestions.

The first parameter of the $LOOKUP function is the column. It is necessary to provide the column even in situations where the source of metadata is generic. At first glance, it may appear that synonyms derived from the thesaurus would be the same regardless of the column; however, the way the synonyms are presented will vary depending on the types of indexes installed on the column. For example, the synonym motor vehicle becomes the phrase search “motor vehicle” or motor BEFORE(1) vehicle on columns indexed with proximity, but becomes motor AND vehicle on a non-proximity indexes. For this reason, the column must always be provided. Furthermore, since the table cannot be determined from the FROM clause, the column parameter must contain a table-qualified column name.

There are two situations when the column parameter may be omitted. The column parameter is not required at all when looking up the textual metadata for definitions. The column parameter is optional when looking up suggestions against the thesaurus.

Figure 31 - The $LOOKUP Function

$LOOKUP(column, ‘word’ [,’options’ [, length]])

column The column to be used in the lookup.

word The word(s) to be used in the search.

options An optional parameter that controls options for the function. These can be any of the ones shown below, as well as options from the $CONTAINS function.

DEFINITIONS Retrieve the definitions of this word or phrase.

SUGGESTIONS[=list] Retrieve the possible suggestions for this word or phrase, using the named list if specified. To retrieve the suggestions based on the content of a column, provide the column in the column parameter.

PARTOFSPEECH=pos When searching the thesaurus or dictionary, limit to the named part of speech. Parts of speech are:

				NOUN
				VERB
				ADJECTIVE
				ADVERB

SENSE=n When searching the thesaurus or dictionary, limit to the specified sense.

MAX_SUGGESTIONS=n Limit to n suggestions.

SCORES Return scores with suggestions

COUNTS Return counts with suggestions, and validate that suggestions will qualify rows.

VALIDATE Validate that suggestions will qualify rows

The following options control the formatting of the output of the LOOKUP function when the SUGGESTIONS or DEFINITIONS options are used.

STYLE= Render the result in the following style:

	TEXT (default)
	HTML

CLASSES Return the result preformatted using HTML classes.

FORMAT= Render the result using the following format:

	FORMATTED (default)
	COMPRESSED

PAGEWIDTH=n Render the result formatted to the following pagewidth.

WORD_URL= Use the following URL in an HTML href tag for the word with a definition.

POS_URL= Use the following URL in an HTML href tag for the part of speech within a definition.

DEF_URL= Use the following URL in an HTML href tag for the definition number within a definition.

CATEGORY_URL= Use the following URL in an HTML href tag for the category within a definition.

ALT_WORD_URL= Use the following URL in an HTML href tag for the alternate word within a definition.

SUGGESTION_URL= Use the following URL in an HTML href tag for the suggestion.

length An optional parameter that controls the length of the string to be returned. If this parameter is not provided, the default size is 4096 bytes.

The $LOOKUP function returns a buffer of datatype C STRING using the default length, or the length specified in the parameters.

 
Back to top
dev/sql/functions/lookup/home.txt · Last modified: 2016/06/28 22:38 (external edit)