Oracle full-Text retrieval notes

Source: Internet
Author: User

1. Delete the lexical parser

exec ctx_ddl.drop_preference (' my_lexer ');

2. Create Chinese lexical parser

exec ctx_ddl.create_preference (' my_lexer ', ' chinese_vgram_lexer ');

3. Create full-text index, multi-field

EXEC ctx_ddl.create_preference (' ctx_idx_jdw_person_pref ', ' multi_column_datastore ');

EXEC ctx_ddl.set_attribute (' ctx_idx_jdw_person_pref ', ' columns ', ' name,address ');

CREATE INDEX Ctx_idx_jdw_person on Jdw_person (name) Indextype is Ctxsys. CONTEXT PARAMETERS (' DATASTORE ctx_idx_jdw_person_pref lexer my_lexer ');

4. Cut words

EXEC ctx_ddl. Create_policy (' my_policy ', LEXER = ' my_lexer ');

Create or Replace function P_split_chinese (p_input in VARCHAR2)
return VARCHAR2 AS
V_tab Ctx_doc. Token_tab;
V_return VARCHAR2 (323767);
Begin
Ctx_doc. Policy_tokens (' My_policy ', p_input,v_tab);
For I in 1..v_tab.count loop
V_return: = V_return | | ', ' | | V_tab (i). token;
End Loop;
Return LTRIM (V_return, ', ');
End
/

5. Synchronization and optimization

exec ctx_ddl.sync_index (' Ctx_idx_jdw_person ');

exec ctx_ddl.optimize_index (' Ctx_idx_jdw_person ', ' full ');

6. Create a timed task to periodically optimize and synchronize the domain index

sql> Create or replace procedure Hsp_sync_index as
2 begin
3 Ctx_ddl.sync_index (' id_cont_msg ');
4 End;
5/

Procedure created.

elapsed:00:00:00.08
Sql> VARIABLE jobno number;
Sql> BEGIN
2 dbms_job. SUBMIT (: Jobno, ' hsp_sync_index (); ',
3 Sysdate, ' Sysdate + (1/24/4) ');
4 commit;
5 END;
6/

PL/SQL procedure successfully completed.

elapsed:00:00:00.27
sql> Create or replace procedure Hsp_optimize_index as
2 begin
3 Ctx_ddl.optimize_index (' id_cont_msg ', ' full ');
4 End;
5/

Sql> VARIABLE jobno number;
Sql> BEGIN
2 dbms_job. SUBMIT (: Jobno, ' hsp_optimize_index (); ',
3 Sysdate, ' sysdate + 1 ');
4 commit;
5 END;
6/
Procedure created.

elapsed:00:00:00.03

PL/SQL procedure successfully completed.

elapsed:00:00:00.02
Sql>

Oracle full-Text retrieval notes

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.