设为首页 加入收藏

TOP

Oracle全文检索方面的研究(全2)(一)
2014-11-24 08:12:01 来源: 作者: 【 】 浏览:2
Tags:Oracle 全文检索 面的 研究

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_fi

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle全文检索方面的研究(全6) 下一篇采用MYSQL存储OpenVPN验证信息

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C/C++ 类模板与模板 (2025-12-27 01:49:52)
·C语言 模板化<templ (2025-12-27 01:49:49)
·C/C++模板类模板与函 (2025-12-27 01:49:46)
·如何理解c语言指针和 (2025-12-27 01:19:11)
·为什么C标准库没有链 (2025-12-27 01:19:08)