设为首页 收藏本站
查看: 564|回复: 0

[经验分享] 【引用】Oracle全文检索方面的研究(全2)

[复制链接]
YunVN网友  发表于 2016-8-14 07:33:27 |阅读模式
3.2 Filter 属性
过滤器负责将各种文件格式的数据转换为纯文本格式,索引管道中的其他组件只能处理纯文本数据,不能识别 microsoft word 或 excel 等文件格式,filter 有charset_filter、
inso_filter、null_filter、user_filter、procedure_filter 几种类型。(可将文档格式转化为数据库文本格式等。)
 
 
 
 
 
3.2.1 CHARSET_FILTER
把文档从非数据库字符转化成数据库字符(原文:Use the CHARSET_FILTER to convert
documents from a non-database character set to the character set used by the database)
 
例子:
create table hdocs ( id number primary key, fmt varchar2(10), cset varchar2(20),
text varchar2(80)
);
begin
cxt_ddl.create.preference('cs_filter', 'CHARSET_FILTER');
ctx_ddl.set_attribute('cs_filter', 'charset', 'UTF8');
end
insert into hdocs values(1, 'text', 'WE8ISO8859P1', '/docs/iso.txt');
insert into hdocs values (2, 'text', 'UTF8', '/docs/utf8.txt');
commit;
create index hdocsx on hdocs(text) indextype is ctxsys.context
parameters ('datastore ctxsys.file_datastore
filter cs_filter
format column fmt
charset column cset');
 
 
 
3.2.2 NULL_FILTER
默认属性,不进行任何过滤
oracle 不建议对html、xml 和plain text 使用auto_filter 参数,oracle 建议你使用
null_filter 和section group type
--建立null filter
create index myindex on docs(htmlfile) indextype is ctxsys.context
parameters('filter ctxsys.null_filter section group ctxsys.html_section_group');
Filter 的默认值会受到索引字段类型和datastore 的类型的影响,对于存储在数据库中的
varchar2、char 和clob 字段中的数据,oracle 自动选择了null_filtel,若datastore 的属性设置为
file_datastore,oracle 会选择 auto_filter 作为默认值。
 
3.2.3 AUTO_FILTER
通用的过滤器,适用于大部分文档,包括PDF 和Ms word,过滤器还会自动识别出plain-text, HTML, XHTML,
SGML 和XML 文档
Create table my_filter (id number, docs varchar2(1000));
Insert into my_filter values (1, 'Expert Oracle Database Architecture.pdf');
Insert into my_filter values (2, '1.txt');
Insert into my_filter values (3, '2.doc');
commit;
/
--建立 file datastore
Begin
ctx_ddl.create_preference('test_filter', 'file_datastore');
ctx_ddl.set_attribute('test_filter', 'path', '/opt/tmp');
End;
--错误信息表
select * from CTX_USER_INDEX_ERRORS
--建立 auto filter
Create index idx_m_filter on my_filter (docs) indextype is ctxsys.context
parameters ('datastore test_filter filter ctxsys.auto_filter');
select * from my_filter where contains(docs,'oracle')>0
 
AUTO_FILTER 能自动识别出大部分格式的文档,我们也可以显示的通过column 来指定文档类型,有text,binary,ignore,设置为binary 的文档使用auto_filter,设置为text 的文档使用null_filter,设置为ignore的文档不进行索引。
create table hdocs (id number primary key,fmt varchar2(10),text varchar2(80));
insert into hdocs values(1, 'binary', '/docs/myword.doc');
insert in hdocs values (2, 'text', '/docs/index.html');
insert in hdocs values (2, 'ignore', '/docs/1.txt');
commit;
create index hdocsx on hdocs(text) indextype is ctxsys.context
parameters ('datastore ctxsys.file_datastore filter ctxsys.auto_filter format column
fmt');
 
3.2.4 MAIL_FILTER
通过mail_filter 把RFC-822,RFC-2045 信息转化成索引文本
限制:
文档必须是us-ascii
长度不能超过1024bytes
document must be syntactically valid with regard to RFC-822
 
 
3.2.5 USER_FILTER
Use the USER_FILTER type to specify an external filter for filtering documents in a column
 
3.2.6 PROCEDURE_FILTER
Use the PROCEDURE_FILTER type to filter your documents with a stored procedure. The stored procedure is called
each time a document needs to be filtered.
 
3.2.7 参考脚本
--建立null filter
create index myindex on docs(htmlfile) indextype is ctxsys.context
parameters('filter ctxsys.null_filter section group ctxsys.html_section_group');
--建立 auto filter
Create index idx_m_filter on my_filter (docs) indextype is ctxsys.context
parameters ('datastore test_filter filter ctxsys.auto_filter');
 
Filter 错误记录表:CTX_USER_INDEX_ERRORS
 
 

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-257567-1-1.html 上篇帖子: Oracle 树形SQL语句,SYS_CONNECT_BY_PATH 函数 下篇帖子: Oracle ADF中实现输入框字数统计功能
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表