Oracle全文检索方面的研究(全3)

来源:未知 责任编辑:责任编辑 发表时间:2014-01-06 18:19 点击:

3.3 Lexer 属性

                Oracle 全文检索的lexer 属性用于处理各种不同的语言,最基本的英文使用basic_lexer,

中文则可以使用chinese_vgram_lexer 或chinese_lexer。

 

 

 

 

 

 

 

 

3.3.1 Basic_lexer

basic_lexer 属性支持如英语、德语、荷兰语、挪威语、瑞典语等以空格作为界限的语言(原

文:Use the BASIC_LEXER type to identify tokens for creating Text indexes for English and all

other supported whitespace-delimited languages.)

Create table my_lex (id number, docs varchar2(1000));

Insert into my_lex values (1, this is a example for the basic_lexer);

Insert into my_lex values (2, he following example sets Printjoin characters );

Insert into my_lex values (3, To create the INDEX with no_theme indexing and with printjoins characters);

Insert into my_lex values (4, 中华人民共和国);

Insert into my_lex values (5, 中国淘宝软件);

Insert into my_lex values (6, 测试basic_lexer 是否支持中文);

Commit;

 

/

--建立basic_lexer

begin

ctx_ddl.create_preference(mylex, BASIC_LEXER);

ctx_ddl.set_attribute (mylex, printjoins, _-); --保留_ -符号

ctx_ddl.set_attribute ( mylex, index_themes, NO);

ctx_ddl.set_attribute ( mylex, index_text, YES);

ctx_ddl.set_attribute (mylex,mixed_case,yes); --区分大小写

end;

create index indx_m_lex on my_lex(docs) indextype is ctxsys.context parameters(lexer

mylex);

Select id from my_lex where contains(docs, no_theme) > 0;

select docs from my_lex where contains(docs,中国)>0

 

3.3.2 Mutil_lexer

支持多种语言的文档,比如你可以利用这个lexer 来定义包含Endlish,German 和Japanese 的

文档(原文:Use MULTI_LEXER to index text columns that contain documents of different

languages. For example, you can use this lexer to index a text column that stores English, German,

and Japanese documents.)建立一个multi_lexer 属性的索引,并通过language 列设置需要索

引的语言,Oracle 会根据language 列的内容去匹配add_sub_lexer 过程中指定的语言标识符,如果匹配的上,就使用该sub_lexer 作为索引的lexer,如果没有找到匹配的,就使用default语言作为索引的lexer 列,注意客户端nls_language,可能会影响lexer 的选择

 

Select * from v$nls_parameters where parameter = NLS_LANGUAGE;

alter session set nls_language=simplified chinese;

alter session set nls_language=american;

 

 

例子:

create table globaldoc ( doc_id number primary key,lang varchar2(3),text clob);

--建立multi_lexer

begin

ctx_ddl.create_preference(english_lexer,basic_lexer);

ctx_ddl.set_attribute(english_lexer,index_themes,yes);

ctx_ddl.set_attribute(english_lexer,theme_language,english);

ctx_ddl.create_preference(german_lexer,basic_lexer);

ctx_ddl.set_attribute(german_lexer,composite,german);

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • Table函数使用简介
  • Oracle数据库Constraint约束的常用操作及异常处理
  • Bulk Collect性能分析(zz)
  • export/import的使用
  • OCP043第十五讲 Database Security
  • ORACLE10gr2数据导入MySQL方案
  • oracle 让sys用户可以使用isqlplus
  • 在oracle数据库下使用iSQL*Plus DBA访问数据库
  • Oracle行列转换小结
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1