oracle 全文检索技术
生活随笔
收集整理的這篇文章主要介紹了
oracle 全文检索技术
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.查看用戶: select * from dba_users WHERE username='CTXSYS';select * from dba_users WHERE username='CTXSYS'; 查看角色 select * from dba_roles WHERE ROLE = 'CTXAPP' 解鎖用戶: ALTER USER CTXSYS ACCOUNT UNLOCK; 角色授權(quán): GRANT CTXAPP TO YLFWZB;或者GRANT EXECUTE ON ctx_ddl TO YLFWZB; 2.建立索引,并設(shè)置索引參數(shù) BEGIN
? CTX_DDL.CREATE_PREFERENCE('my_datastore_prefs1', 'FILE_DATASTORE');
? CTX_DDL.SET_ATTRIBUTE('my_datastore_prefs1', 'path', 'F:\file');--?數(shù)據(jù)存儲(chǔ)(Datastore)類
? CTX_DDL.CREATE_PREFERENCE('my_lexer', 'chinese_lexer');---?詞法分析器(Lexer)類
? --? ctx_ddl.create_stoplist('my_stoplist'); --?非索引字表(Stoplist)類
? --? ctx_ddl.add_stopword('my_stoplist','有限公司');?
? --? ctx_ddl.add_stopword('my_stoplist','股份有限公司');
? --create index YU_TEST_INDEX on YU_TEST(name) indextype is CTXSYS.CONTEXT parameters('lexer my_lexer stoplist my_stoplist');?
? --create index mydocs_text_index on mydocs(thefile) indextype is ctxsys.context parameters('datastore mydatastore_prefs Filter ctxsys.inso_filter Lexer my_lexer'); --ctx_ddl.drop_preference('my_datastore_prefs1');刪除索引參數(shù)
END; 【權(quán)限報(bào)錯(cuò)處理方式: BEGIN ctxsys.ctx_adm.set_parameter('file_access_role', 'public');
END;】 【查看索引使用錯(cuò)誤信息 select * from ctxsys.ctx_user_index_errors; 】 4.建表,索引 create table mydocs(id number primary key,title varchar2(255),thefile varchar2(255));
?
create index mydocs_text_index on mydocs(thefile) indextype is ctxsys.context parameters('datastore my_datastore_prefs1 Filter ctxsys.inso_filter Lexer my_lexer'); --thefile必須是非中文 INSERT INTO MYDOCS (ID, TITLE, THEFILE) VALUES (1, 'DOC1', '1.doc');
? INSERT INTO MYDOCS (ID, TITLE, THEFILE) VALUES (2, 'DOC1', '2.docx');
? INSERT INTO MYDOCS (ID, TITLE, THEFILE) VALUES (3, 'DOC1', '3.pdf'); 【自動(dòng)產(chǎn)生的表?DR$myindex$I,DR$myindex$K,DR$myindex$R,DR$myindex$N】 5.同步索引 begin
??? ctx_ddl.sync_index('mydocs_text_index');
??? ctx_ddl.optimize_index('mydocs_text_index','full');
??? END; 6.測(cè)試是否成功 select * from mydocs? where contains(thefile,'興趣')>0; 總結(jié): oracle text 大文本檢索 適合的場(chǎng)景:應(yīng)用服務(wù)器和數(shù)據(jù)庫(kù)服務(wù)器在同一個(gè)服務(wù)器中。如果不是就考慮apache 的luence技術(shù)代替 參考的文章: http://baike.baidu.com/link?url=IWkJgbj3O2XvNsdfJ8EfQCZlau2-_8525h9PP2MwUiUGd1urZtxhRFGT3FLCYWxj http://www.cnblogs.com/mybook/archive/2012/12/17/2822299.html http://wenku.baidu.com/link?url=ma_NAYuttTOX_C-bjFa2YzjSNiXSwCEcFS4iba5mtkJTr_1kw7rht0XG6CSbEr3LIybOKq6HmZv0h3ixRrrFS09PDk-cQHu8oT62JW11Iea http://blog.csdn.net/pathuang68/article/details/4093665 http://www.iteye.com/topic/1118055 http://blog.csdn.net/njslh/article/details/8681502 比較詳細(xì): http://it.chinawin.net/database/article-125fc.html contain用法 http://www.blogjava.net/rebel/archive/2007/01/10/92894.html 網(wǎng)頁檢索: http://www.doc88.com/p-050298145400.html 進(jìn)階: http://blog.chinaunix.net/uid-42518-id-2404669.html http://www.docin.com/p-419740081.html http://blog.itpub.net/271283/viewspace-1022075/
? CTX_DDL.CREATE_PREFERENCE('my_datastore_prefs1', 'FILE_DATASTORE');
? CTX_DDL.SET_ATTRIBUTE('my_datastore_prefs1', 'path', 'F:\file');--?數(shù)據(jù)存儲(chǔ)(Datastore)類
? CTX_DDL.CREATE_PREFERENCE('my_lexer', 'chinese_lexer');---?詞法分析器(Lexer)類
? --? ctx_ddl.create_stoplist('my_stoplist'); --?非索引字表(Stoplist)類
? --? ctx_ddl.add_stopword('my_stoplist','有限公司');?
? --? ctx_ddl.add_stopword('my_stoplist','股份有限公司');
? --create index YU_TEST_INDEX on YU_TEST(name) indextype is CTXSYS.CONTEXT parameters('lexer my_lexer stoplist my_stoplist');?
? --create index mydocs_text_index on mydocs(thefile) indextype is ctxsys.context parameters('datastore mydatastore_prefs Filter ctxsys.inso_filter Lexer my_lexer'); --ctx_ddl.drop_preference('my_datastore_prefs1');刪除索引參數(shù)
END; 【權(quán)限報(bào)錯(cuò)處理方式: BEGIN ctxsys.ctx_adm.set_parameter('file_access_role', 'public');
END;】 【查看索引使用錯(cuò)誤信息 select * from ctxsys.ctx_user_index_errors; 】 4.建表,索引 create table mydocs(id number primary key,title varchar2(255),thefile varchar2(255));
?
create index mydocs_text_index on mydocs(thefile) indextype is ctxsys.context parameters('datastore my_datastore_prefs1 Filter ctxsys.inso_filter Lexer my_lexer'); --thefile必須是非中文 INSERT INTO MYDOCS (ID, TITLE, THEFILE) VALUES (1, 'DOC1', '1.doc');
? INSERT INTO MYDOCS (ID, TITLE, THEFILE) VALUES (2, 'DOC1', '2.docx');
? INSERT INTO MYDOCS (ID, TITLE, THEFILE) VALUES (3, 'DOC1', '3.pdf'); 【自動(dòng)產(chǎn)生的表?DR$myindex$I,DR$myindex$K,DR$myindex$R,DR$myindex$N】 5.同步索引 begin
??? ctx_ddl.sync_index('mydocs_text_index');
??? ctx_ddl.optimize_index('mydocs_text_index','full');
??? END; 6.測(cè)試是否成功 select * from mydocs? where contains(thefile,'興趣')>0; 總結(jié): oracle text 大文本檢索 適合的場(chǎng)景:應(yīng)用服務(wù)器和數(shù)據(jù)庫(kù)服務(wù)器在同一個(gè)服務(wù)器中。如果不是就考慮apache 的luence技術(shù)代替 參考的文章: http://baike.baidu.com/link?url=IWkJgbj3O2XvNsdfJ8EfQCZlau2-_8525h9PP2MwUiUGd1urZtxhRFGT3FLCYWxj http://www.cnblogs.com/mybook/archive/2012/12/17/2822299.html http://wenku.baidu.com/link?url=ma_NAYuttTOX_C-bjFa2YzjSNiXSwCEcFS4iba5mtkJTr_1kw7rht0XG6CSbEr3LIybOKq6HmZv0h3ixRrrFS09PDk-cQHu8oT62JW11Iea http://blog.csdn.net/pathuang68/article/details/4093665 http://www.iteye.com/topic/1118055 http://blog.csdn.net/njslh/article/details/8681502 比較詳細(xì): http://it.chinawin.net/database/article-125fc.html contain用法 http://www.blogjava.net/rebel/archive/2007/01/10/92894.html 網(wǎng)頁檢索: http://www.doc88.com/p-050298145400.html 進(jìn)階: http://blog.chinaunix.net/uid-42518-id-2404669.html http://www.docin.com/p-419740081.html http://blog.itpub.net/271283/viewspace-1022075/
轉(zhuǎn)載于:https://www.cnblogs.com/fireman/p/3684086.html
總結(jié)
以上是生活随笔為你收集整理的oracle 全文检索技术的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: z-index优先级总结
- 下一篇: Xcode5 使用gitHub上库的SS