Oracle full-text index settings

Source: Internet
Author: User
Tags lexer
Guidance:
Several project teams have begun to use the full-text index of oracle. Oracle's lexical analyzer is not smart enough for the lexical analysis of the zhs16gbk character set. It can only be mechanically matched in words. The utf8 character set database has a new Chinese analyzer chinese_lexer, which greatly improves the efficiency. The documents on how to configure full-text Oracle indexes have been verified and sorted out, applicable to the 8i and 9i platform versions.
For DB2, there is a plug-in called text information extend that can implement full-text indexing, But it is said that its syntax analysis is also very primitive. According to reports, the use of CM (Content Manager) can achieve better full-text retrieval, but requires a lot of software, not suitable for simple applications.
1. Create a database
1. Select jserver and intermedia when creating a database using dbassist.
2. Check whether intermedia is installed in your database. You can check whether there are ctxsys users and ctxapp roles (role ).
3. If you do not have this user or role, it means that the intermedia function is not installed when the database is created. You must modify the database to install this feature. Modification Process:
Run $ ORACLE_HOME/bin/dbassist, select 'modify database', and select jserver and intermedia when selecting the database function (jserver must be installed at the same time when intermedia is installed ).
Ii. Set EXTPROC
Oracle uses the 'external call function' (external procedure) to implement intermedia. Therefore, setting EXTPROC correctly is a key step. Generally, EXTPROC has been set in listener. ora and tnsnames. ora after jserver and intermedia are installed in the database.
1 , Test EXTPROC Normal?
Restart listener and use tnsping to test whether the configuration is correct,
Run the command line
Tnsping extproc_connection_data or
Tnsping extproc_connection_data.world
If the configuration is correct, the following information is displayed:
Attempting to contact (address = (Protocol = IPC) (Key = EXTPROC) OK (140 ms)
If it is correct, skip steps 2 and 3. Otherwise, follow the steps 2 and 3 to set the listener. ora and tnsnames. ora files. After modification, you must restart listener, but you do not need to restart the database.
2. Set listerner. ora
If tnsping fails, you need to configure listener to enable it to listen to requests called by Intermedia. You can run $ ORACLE_HOME/bin/netassit to configure the listener. You can also manually modify the configuration file $ ORACLE_HOME/Network/admin/listener. ora and restart listener.
The following example shows how to manually modify the configuration file:
Open the listener. ora file. Before modification, there are usually the following content (assuming the default listener is used ):
Listener =
(Description =
(Address = (Protocol = TCP) (host = mydatabase) (Port = 1521 ))
)
Sid_list_listener =
(Sid_desc =
(Global_dbname = mydatabase. World)
(ORACLE_HOME =/u01/APP/Oracle/product/8.1.6)
(Sid_name = mydatabase)
)
Extproc has not been configured for this listener. Therefore, you need to add a listener to EXTPROC by adding description and sid_desc respectively. The modified listner. ora is as follows:
Listener =
(Description_list =
(Description =
(Address = (Protocol = TCP) (host = mydatabase) (Port = 1521 ))
)
(Description =
(Address = (Protocol = IPC) (Key = EXTPROC ))
)
)
Sid_list_listener =
(Sid_list =
(Sid_desc =
(Global_dbname = mydatabase. World)
(ORACLE_HOME =/u01/APP/Oracle/product/8.1.6)
(Sid_name = mydatabase)
)
(Sid_desc =
(Program = EXTPROC)
(Sid_name = plsextproc)
(ORACLE_HOME =/u01/APP/Oracle/product/8.1.6)
)
)
Note that the above host, global_dbname, sid_name, ORACLE_HOME should fill in the actual value of your database, but the actual value of program must be EXTPROC.
3. Set tnsnames. ora
Configure the tnsnames. ora file on the server. The file is located under $ ORACLE_HOME/Network/admin. You can also configure it by running netasst.
Add the following to the tnsnames. ora file:
Extproc_connection_data, extproc_connection_data.world =
(Description =
(Address_list =
(Address = (Protocol = IPC) (Key = EXTPROC ))
)
(CONNECT_DATA =
(SID = plsextproc)
)
)
Note that the key and Sid must be the same as the key and sid_name in listener. ora.
3. Set the lexical analyzer (lexer)
Oracle uses the basic_lexer analyzer by default. Basic_lexer is for English. To specify a Chinese analyzer, follow these steps:
1. Use the ctxsys user to log on to intermedia text Manager. The password is ctxsys:
2. Select "preference"> "Language Indicator"> "CREATE". enter the name of the indicator, for example, "chinese_vgrnm_lexer", and select "chinese_vgrnm_lexer" under "lexer.
3. Create an intermedia index, specify the index name, select the scheme and table fields, for example, the currenttext field in dom_1_doclib in the system scheme, and select chinese_lexer in the preference.
In this way, chinese_vgram_lexer is used as the analyzer.
4. After the index is created, Oracle automatically generates the following tables under this user. You can use DBA studio to view the tables: (assuming the index name is myindex ):
Dr $ myindex $ I, Dr $ myindex $ K, Dr $ myindex $ R, Dr $ myindex $ n
The I table is the most important. query this table:
Select token_text, token_count from Dr $ I _rsk1 $ I where rownum <= 20;
You can see that the table stores the term records generated after Oracle analyzes your documents, including the location, number of times, and hash value of the term.
4. Use job timed synchronization and Optimization
After the intermedia index is created, if the data in the table changes and the record is added or modified, the index is not automatically modified because any DML statements occur on the table, you must regularly synchronize (Sync) and optimize (optimize) indexes to correctly reflect data changes.
Sync: Save the new term to the I table;
Optimize: clears the garbage from the I table, mainly to delete the deleted term from the I table.
Oracle provides a CTX server for synchronization and optimization. You only need to run the process in the background. It monitors data changes and synchronizes data in a timely manner. But there are many problems. You can run the following two jobs (the job must be created under the same user as the table ):
-- Sync:
Variable jobno number;
Begin
Dbms_job.submit (: jobno, 'ctx _ DDL. sync_index ('myindex ');',
Sysdate, 'sysdate + (1/24/4 )');
Commit;
End;
-- Optimizer
Variable jobno number;
Begin
Dbms_job.submit (: jobno, 'ctx _ DDL. optimize_index ('myindex', 'full ');',
Sysdate, 'sysdate + 1 ');
Commit;
End;
The sysdate + (1/24/4) of the first job is synchronized every 15 minutes. The sysdate + 1 of the second job is fully optimized every one day. The specific time interval can be determined based on your application needs. So far, your full-text search function has been set up.

This article is transferred from
Http://oracle.itpub.net/post/20957/224820

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.