Oracle8i interMedia Text Reference Release 8.1.5 A67843-01 |
|
This chapter introduces the concepts necessary for understanding the index preference objects supplied with interMedia Text.
The following topics are discussed in this chapter:
When you use CREATE INDEX to create an index or ALTER INDEX to manage an index, you can optionally specify indexing preferences, stoplists, and section groups in the parameter string. Specifying a preference, stoplist, or section group answers one of the following questions about the way Oracle indexes text:
This chapter describes the options you have for setting each preference. You enable an option by creating a preference with one of the objects described in this chapter.
For example, to specify that your documents are stored in external files, you can create a datastore preference called mydatastore using the FILE_DATASTORE object and specify mydatastore as the datastore preference in the parameter string of CREATE INDEX.
To create a datastore, lexer, filter, wordlist, or storage preference, you use CTX_DDL.CREATE_PREFERENCE procedure and specify one of the objects described in this chapter. For some objects, you can also set attributes with CTX_DDL.SET_ATTRIBUTE.
To create a stoplists, use CTX_DDL.CREATE_STOPLIST.
To create section groups, use CTX_DDL.CREATE_SECTION_GROUP and specify a section group type.
Use the datastore objects to specify how your text is stored. To create a data storage preference, you must use one of the following objects:
Use the DIRECT_DATASTORE object for text stored directly in the database. It has no attributes.
Use the DETAIL_DATASTORE object for text stored directly in the database in detail tables, with the textkey column located in the master table.
DETAIL_DATASTORE has the following attributes:
This example illustrates how master and detail tables are related to each other.
Master tables define the documents in a master/detail relationship. You assign an identifying number to each document. The following table is an example master table, called my_master:
Detail tables contain the text for a document, whose content is usually stored across a number of rows. The following detail table my_detail is related to the master table my_master with the article_id column. This column identifies the master document to which each detail row (sub-document) belongs.
Column Name | Column Type | Description |
---|---|---|
article_id |
NUMBER |
Document ID that relates to master table. |
seq |
NUMBER |
Sequence of document in the master document defined by article_id. |
text |
CLOB |
Document text. |
In this example, the DETAIL_DATASTORE attributes have the following values:
Attribute | Attribute Value |
---|---|
binary |
TRUE |
detail_table |
my_detail |
detail_key |
article_id |
detail_lineno |
seq |
detail_text |
text |
You use CTX_DDL.CREATE_PREFERENCE to create a preference with DETAIL_DATASTORE. You use CTX_DDL.SET_ATTRIBUTE to set the attributes for this preference as described above. The following example shows how this is done:
begin ctx_ddl.create_preference('my_detail_pref', 'DETAIL_DATASTORE'); ctx_ddl.set_attribute('my_detail_pref', 'binary', 'true'); ctx_ddl.set_attribute('my_detail_pref', 'detail_table', 'my_detail'); ctx_ddl.set_attribute('my_detail_pref', 'detail_key', 'article_id'); ctx_ddl.set_attribute('my_detail_pref', 'detail_lineno', 'seq'); ctx_ddl.set_attribute('my_detail_pref', 'detail_text', 'text'); end;
To index the document defined in this master/detail relationship, you specify a column in the master table with CREATE INDEX. The column you specify must be one of the allowable types.
This example uses the body column, whose function is to allow the creation of the master/detail index and to improve readability of the code. The my_detail_pref preference is set to DETAIL_DATASTORE with the required attributes:
CREATE INDEX myindex on my_master(body) indextype is context parameters('datastore my_detail_pref');
In this example, you can also specify the title or author column to create the index. However, if you do so, changes to these columns will trigger a re-index operation.
The FILE_DATASTORE object is used for text stored in files accessed through the local file system.
FILE_DATASTORE has the following attribute(s):
Attribute | Attribute Values |
---|---|
path |
path1:path2:...:pathn |
Specify the location of text files that are stored externally in a file system.
You can specify multiple paths for path, with each path separated by a colon (:). File names are stored in the text column in the text table. If path is not used to specify a path for external files, Oracle requires the path to be included in the file names stored in the text column.
Use the URL_DATASTORE object for text stored:
You store each URL in a single text field.
The syntax of a URL you store in a text field must comply with the RFC 1738 specification. The syntax of this specification is as follows:
[URL:]<access_scheme>://[<user_id>:<password>@]<host_name>[:<port_number>]/[<url_path>]
The access_scheme string is either ftp, http, or file.
As part of the RFC 1738 specification, the following restriction holds for the URL syntax:
URL_DATASTORE has the following attributes:
Specify the length of time, in seconds, that a network operation such as a connect or read waits before timing out and returning a timeout error to the application. The valid range for timeout is 15 to 3600 and the default is 30.
Specify the maximum number of threads that can be running at the same time. The valid range for maxthreads is 1 to 1024 and the default is 8.
Specify the maximum length, in bytes, that the URL data store supports for URLs stored in the database. If a URL is over the maximum length, an error is returned. The valid range for urlsize is 32 to 65535 and the default is 256.
Specify the maximum number of rows that the internal buffer can hold for HTML documents (rows) retrieved from the text table. The valid range for maxurls is 32 to 65535 and the default is 256.
Specify the maximum size, in bytes, that the URL data store supports for accessing HTML documents whose URLs are stored in the database. The valid range for maxdocsize is 1 to 2,147,483,647 (2 gigabytes) and the default is 2,000,000.
Specify the fully-qualified name of the host machine that serves as the HTTP proxy (gateway) for the machine on which interMedia Text is installed. This attribute must be set if the machine is in an intranet that requires authentication through a proxy server to access Web files located outside the firewall.
Specify the fully-qualified name of the host machine that serves as the FTP proxy (gateway) for the machine on which interMedia Text is installed. This attribute must be set if the machine is in an intranet that requires authentication through a proxy server to access Web files located outside the firewall.
Specify a string of domains (up to sixteen, separate by commas) which are found in most, if not all, of the machines in your intranet. When one of the domains is encountered in a host name, no request is sent to the machine(s) specified for ftp_proxy and http_proxy. Instead, the request is processed directly by the host machine identified in the URL.
For example, if the string us.oracle.com, uk.oracle.com is entered for no_proxy, any URL requests to machines that contain either of these domains in their host names are not processed by your proxy server(s).
Use USER_DATASTORE object to define stored procedures that synthesize documents during indexing. For example, a user procedure might synthesize author, date, and text columns into one document to have the author and date information be part of the indexed text.
The USER_DATASTORE has the following attribute:
Attribute | Attribute Value |
---|---|
procedure |
Specify the name of the procedure that synthesizes the document to be indexed. |
Specify the name of the procedure that synthesizes the document to be indexed. This specification must be in the form PROCEDURENAME or PACKAGENAME.PROCEDURENAME. The schema owner name is constrained to CTXSYS, so specifying owner name is not necessary.
The procedure you specify must have the following parameters:
(IN ROWID, IN OUT CLOB)
The procedure is called once for each row indexed. Given the rowid of the current row, the procedure must write the text of the document into the CLOB locator.
The following constraints apply to the procedure you specify:
Use the filter objects to create preferences that determine how text is filtered for indexing. Filters allow word processor and formatted documents, as well as plain text and HTML documents, to be indexed.
For formatted documents, Oracle stores documents in their native format and uses filters to build temporary plain text or HTML versions of the documents. Oracle indexes the plain text/HTML version of the formatted document.
To create a filter preference, you must use one of the following objects:
Filter Preference Object | Description |
---|---|
ASCII filter. |
|
Inso filter for filtering formatted documents. |
|
User-defined filter |
|
Character set converting filter. |
Use the NULL_FILTER object to specify that plain text is stored in the text column and no filtering needs to be performed. NULL_FILTER has no attributes.
The Inso filter is a universal filter that filters most document formats. Use it for indexing single and mixed format columns. The INSO_FILTER has no attributes.
See Also:
For a list of the formats supported by INSO_FILTER and to learn more about how to set up your environment to use this filter, see Appendix C, "Supported Filter Formats". |
Use the USER_FILTER object to specify an external filter for filtering documents in a column. USER_FILTER has the following attribute:
Attribute | Attribute Values |
---|---|
command |
filter executable |
Specify the executable for the single external filter used to filter all text stored in a column. If more than one document format is stored in the column, the external filter specified for command must recognize and handle all such formats.
The executable you specify must go in the $ORACLE_HOME/ctx/bin directory. You must create your user-filter executable with two parameters: the first is the name of the input file to be read, and the second is the name of the output file to be written to.
If all the document formats are supported by the INSO_FILTER, use INSO_FILTER instead of USER_FILTER unless additional tasks besides filtering are required for the documents.
Use the CHARSET_FILTER to convert documents from one character set to the database character set.
The CHARSET_FILTER has the following attribute:
See Also:
For more information about the supported NLS character sets, see Oracle8i National Language Support Guide. |
Use the lexer preference to specify the language of the text to be indexed. To create a lexer object, you must use one of the following objects:
Use the BASIC_LEXER object to identify tokens for creating Text indexes for English and all other supported single-byte languages.
The BASIC_LEXER is also used to enable base-letter conversion, composite word indexing, case-sensitive indexing and alternate spelling for single-byte languages that have extended character sets.
In English, you can use the BASIC_LEXER to enable theme indexing.
BASIC_LEXER has the following attributes:
Specify the characters that indicate a word continues on the next line and should be indexed as a single token. The most common continuation characters are hyphen '-' and backslash '\'.
Specify a single character that, when it appears in a string of digits, indicates that the digits are groupings within a larger single unit.
For example, comma ',' might be defined as numgroup characters because it often indicates a grouping of thousands when it appears in a string of digits.
Specify the characters that, when they appear in a string of digits, cause Oracle to index the string of digits as a single unit or word.
For example, period '.' may be defined as numjoin characters because it often serves as decimal points when it appears in a string of digits.
Specify the non-alphanumeric characters that, when they appear anywhere in a word (beginning, middle, or end), are processed as alphanumeric and included with the token in the Text index. This includes printjoins that occur consecutively.
For example, if the hyphen '-' and underscore '_' characters are defined as printjoins, terms such as pseudo-intellectual and _file_ are stored in the Text index as pseudo-intellectual and _file_.
Specify the non-alphanumeric characters that, when they appear at the end of a word, indicate the end of a sentence. The defaults are period '.', question mark '?', and exclamation point '!'.
Characters that are defined as punctuations are removed from a token before text indexing; however, if a punctuations character is also defined as a printjoins character, the character is only removed if it is the last character in the token and it is immediately preceded by the same character.
For example, if the period (.) is defined as both a printjoins and a punctuations character, the following transformations take place during indexing and querying as well:
Token | Indexed Token |
---|---|
.doc |
.doc |
dog.doc |
dog.doc |
dog..doc |
dog..doc |
dog. |
dog |
dog... |
dog.. |
In addition, BASIC_LEXER uses punctuations characters in conjunction with newline and whitespace characters to determine sentence and paragraph deliminters for sentence/paragraph searching.
Specify the non-alphanumeric characters that, when they appear within a word, identify the word as a single token; however, the characters are not stored with the token in the Text index.
For example, if the hyphen character '-' is defined as a skipjoins, the word pseudo-intellectual is stored in the Text index as pseudointellectual.
Specify the characters that, when encountered as the first character in a token, explicitly identify the start of the token. The character, as well as any other startjoins characters that immediately follow it, is included in the Text index entry for the token. In addition, the first startjoins character in a string of startjoins characters implicitly end the previous token.
endjoins specifies the characters that, when encountered as the last character in a token, explicitly identify the end of the token. The character, as well as any other startjoins characters that immediately follow it, is included in the Text index entry for the token.
The following rules apply to both startjoins and endjoins:
Specify the characters that are treated as blank spaces between tokens. BASIC_LEXER uses whitespace characters in conjunction with punctuations and newline characters to identify character strings that serve as sentence delimiters for sentence/paragraph searching.
The predefined, default values for whitespace are 'space' and 'tab'; these values cannot be changed. Specifying characters as whitespace characters adds to these defaults.
Specify the characters that indicate the end of a line of text. BASIC_LEXER uses newline characters in conjunction with punctuations and whitespace characters to identify character strings that server as paragraph delimiters for sentence/paragraph searching.
The only valid values for newline are NEWLINE and CARRIAGE_RETURN (for carriage returns). The default is NEWLINE.
Specify whether characters that have diacritical marks (umlauts, cedillas, acute accents, etc.) are converted to their base form before being stored in the Text index. The default is NO (base-letter conversion disabled).
Specify whether the lexer converts the tokens in Text index entries to all uppercase or stores the tokens exactly as they appear in the text. The default is NO (tokens converted to all uppercase).
Specify whether composite word indexing is disabled or enabled for either GERMAN or DUTCH text. The default is NO (composite word indexing disabled).
Specify YES to index theme information in English. This makes ABOUT queries more precise. The index_themes and index_text attributes cannot both be NO.
Specify YES to index word information. The index_themes and index_text attributes cannot both be NO.
Specify either GERMAN, DANISH, or SWEDISH to enable alternate spelling in one of these languages. By default, alternate spelling is enabled in all three languages.
See Also:
For more information about the alternate spelling conventions Oracle uses, see Appendix F, "Alternate Spelling Conventions". |
The CHINESE_VGRAM_LEXER object identifies tokens in Chinese text for creating Text indexes. It has no attributes.
The JAPANESE_VGRAM_LEXER object identifies tokens in Japanese for creating Text indexes. It has no attributes.
The KOREAN_LEXER object identifies tokens in Korean text for creating Text indexes. When you use the KOREAN_LEXER, specify the following attributes:
Use the wordlist preference to enable the advanced query options such as stemming and fuzzy matching for your language. To create a wordlist preference, you must use BASIC_WORDLIST, which is the only object available.
Use BASIC_WORDLIST object to enable stemming and fuzzy matching for Text indexes.
See Also:
For more information about the stem and fuzzy operators, see Chapter 4, "Query Operators". |
BASIC_WORDLIST has the following attributes:
Specify the stemmer used for word stemming in Text queries. When there is no stemmer for a language, the default is NULL. With the NULL stemmer, the $ operator is ignored in queries.
Specify which fuzzy matching routines are used for the column. Fuzzy matching is currently supported for English, Japanese, and, to a lesser extent, the Western European languages.
The default for fuzzy_match is GENERIC.
Specify a default lower limit of fuzzy score. Specify a number between 0 and 80. Setting fuzzy score means scores below this number are not produced.
Fuzzy score is a measure of how close the expanded word is to the query word, the higher the score the better the match. Use this parameter to limit fuzzy expansions to the best matches.
Specify the maximum number of fuzzy expansions. Use a number between 0 and 5000.
Setting a fuzzy expansion limits the expansion to a certain number of the best matching words.
Use the storage preference to specify tablespace and creation parameters for tables associated with a Text index. The system provides a single storage object called BASIC_STORAGE:
Object | Description |
---|---|
BASIC_STORAGE |
Indexing object used to specify the tablespace and creation parameters for the database tables and indexes that constitute a Text index. |
The BASIC_STORAGE object specifies the tablespace and creation parameters for the database tables and indexes that constitute a Text index.
The clause you specify is added to the internal CREATE TABLE (CREATE INDEX for the i_index _clause) statement at index creation. You can specify most allowable clauses, such as storage, LOB storage, or partitioning.
However, do not specify an index organized table clause.
See Also:
For more information about how to specify CREATE TABLE and CREATE INDEX clauses, see their command syntax specification in Oracle8i SQL Reference. |
BASIC_STORAGE has the following attributes:
By default, BASIC_STORAGE attributes are not set. In such cases, the Text index tables are created in the index owner's default tablespace. Consider the following statement, issued by user IUSER, with no BASIC_STORAGE attributes set:
create index IOWNER.idx on TOWNER.tab(b) indextype is ctxsys.context
In this example, the tablespace is created in IOWNER's default tablespace.
The following examples specify that the index tables are to be created in the foo tablespace with an initial extent of 1K:
begin ctx_ddl.create_preference('mystore', 'BASIC_STORAGE'); ctx_ddl.set_attribute('mystore', 'I_TABLE_CLAUSE', 'tablespace foo storage (initial 1K)'); ctx_ddl.set_attribute('mystore', 'K_TABLE_CLAUSE', 'tablespace foo storage (initial 1K)'); ctx_ddl.set_attribute('mystore', 'R_TABLE_CLAUSE', 'tablespace foo storage (initial 1K)'); ctx_ddl.set_attribute('mystore', 'N_TABLE_CLAUSE', 'tablespace foo storage (initial 1K)'); ctx_ddl.set_attribute('mystore', 'I_INDEX_CLAUSE', 'tablespace foo storage (initial 1K)'); end;
You can specify one of the following group types to create a section group with CTX_DDL.CREATE_SECTION_GROUP:
When you install interMedia Text, some indexing preferences are created. You can use these preferences in the parameter string of CREATE INDEX or define your own. These preferences are divided into the following categories:
This preference uses the DIRECT_DATASTORE object. It is used to create indexes for text columns in which the text is stored directly in the column.
This preference uses the FILE_DATASTORE object.
This preference uses the URL_DATASTORE object.
This preference uses the NULL_FILTER object.
This preference uses the INSO_FILTER object.
This preference defaults to the lexer required for the language you specify during your database setup.
This preference uses the NULL_SECTION_GROUP object.
This preference uses the HTML_SECTION_GROUP object.
This stoplist preference defaults to the stoplist of the language specified during your database setup.
See Also:
For a complete list of the stop words in the supplied stoplists, see Appendix E, "Supplied Stoplists". |
This storage preference uses the BASIC_STORAGE object.
This preference uses the language stemmer for the language specified during your database setup. If your language is not listed in Table 3-1, this preference defaults to the NULL stemmer and the GENERIC fuzzy matching attribute.
When you install interMedia Text, in addition to the system-defined preferences, the following system parameters are set:
You can view system defaults with CTX_PARAMETERS view. You can change defaults using the CTX_ADM.SET_PARAMETER procedure.
The following default parameters are used when you do not specify preferences in the parameter string of CREATE INDEX. Each default parameter names a pre-defined preference to use for data storage, filtering, lexing and so on.
You can view system defaults with CTX_PARAMETERS view.
You can change a default value using the CTX_ADM.SET_PARAMETER procedure to name another preference, custom or pre-defined, to use as default.