Oracle全文检索方面的研究(全7)
3.7 Stoplist 属性
Stoplist 允许屏蔽某些常用的词,比如is,a,this,对这些词进行索引用处不大,系统
默认会使用和数据库语言相对应的停用词库(原文:Stoplists identify the words in your
language that are not to be indexed. In English, you can also identify stopthemes that are not to be indexed. By default, the system indexes text using the system-supplied stoplist that corresponds to your database language.),Oracle text 提供最常用的停用词库语言包括English, French, German,Spanish, Chinese, Dutch, and Danish
分别有basic_stoplist,empty_stoplist,default_stoplist,multi_stoplist 几种类型
3.7.1 Basic_stoplist
建立用户自定义的停用词库,文档中关于stoplist 的介绍相当少,只有寥寥的数行
例子:
Create table my_stop (id number, docs varchar2(1000));
Insert into my_stop values (1, Stoplists identify the words in your language that are not
to be indexed.);
Insert into my_stop values (2, ou can also identify stopthemes that are not to be indexed);
Commit;
/
--建立basic stoplist
Begin
Ctx_ddl.create_stoplist(test_stoplist, basic_stoplist);
End;
Create index ind_m_stop on my_stop(docs) indextype is ctxsys.context
parameters (stoplist test_stoplist);
Select * from my_stop where contains(docs, words) > 0;
Begin
Ctx_ddl.add_stopword(test_stoplist, language); --添加停用词
ctx_ddl.sync_index(ind_m_stop, 2m); --同步索引
End;
Select * from my_stop where contains(docs, language) > 0; --添加停用词,同步索引后发现还是
能查到,需要重新建立索引才能生效
Drop index ind_m_stop;
Create index ind_m_stop on my_stop(docs) indextype is ctxsys.context
parameters (stoplist test_stoplist);
Select * from my_stop where contains(docs, language) > 0; --停用词生效
添加停用词,同步索引后发现还是能查到,需要重新建立索引才能生效。
3.7.2 Empty_stoplist
停用词库没有任何停用词,适用于不需要过滤的查询中,如不需要过滤is this,a 等
3.7.3 Default_stoplist
建立basic_stoplist 后,里面不包含任何的停用词,而default_stoplist 在basic_stoplist 的基础
上增加了预定义的默认停用词,对于不同的语言,默认的停用词库数据也不一样
例子:
Create table my_stop (id number, docs varchar2(1000));
Insert into my_stop values (1, Stoplists identify the words in your language that are not
to be indexed.);
Insert into my_stop values (2, ou can also identify stopthemes that are not to be indexed);
Commit;
/
--建立lexer,不同lexer 属性会默认不同的停用词库
Begin
ctx_ddl.create_preference(test_b_lexer, basic_lexer);
End;
drop index ind_m_word;
--建立默认停用词default_stoplist
Create index ind_m_word on my_stop(docs) indextype is ctxsys.context
Parameters (lexer test_b_lexer stoplist ctxsys.default_stoplist);
--检查默认词库中是否存在
Select * from my_stop where contains(docs, the) > 0;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>