首页 > 数据库 >【引用】Oracle全文检索方面的研究(全2)

【引用】Oracle全文检索方面的研究(全2)

时间:2023-09-21 11:34:26浏览次数:45  
标签:hdocs text filter 全文检索 引用 docs Oracle datastore ctxsys


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

 

 

标签:hdocs,text,filter,全文检索,引用,docs,Oracle,datastore,ctxsys
From: https://blog.51cto.com/u_16255870/7552212

相关文章

  • 【引用】Oracle全文检索方面的研究(全9)
    3.10常用的脚本3.10.1.删除preference:beginctx_ddl.drop_preference('my_lexer');end; 3.10.2.索引重建:ALTERINDEXnewsindexREBUILDPARAMETERS('replacelexermy_lexer'); 3.10.3同步索引beginctx_ddl.sync_index('myindex','2M');end;或通过后......
  • oracle查看实例EM端口号、SID设制与一些命令
    一、查看数据库实例的EM端口在ORACLE_HOME\install\portlist.ini文件里面。二、设制数据库实例的SIDSID的长度不能超过8个字符。实例名不能超过30个字符三、常用的一些命令启动/关闭EM:emctlstart/stopdbconsole启动/关闭监听:lsnrctlstart/stop创......
  • oracle 9i 建立oracle 10g dblink
    在oracle9i的机器的tnsnames.ora里配置10g的服务名为:ora10g=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ip)(PORT=1522)))(CONNECT_DATA=(SERVICE_NAME......
  • Oracle表空间操作详解(备份)
    建立表空间CREATETABLESPACEdata01DATAFILE'/oracle/oradata/db/DATA01.dbf'SIZE500MUNIFORMSIZE128k;#指定区尺寸为128k,如不指定,区尺寸默认为64k删除表空间DROPTABLESPACEdata01INCLUDINGCONTENTSANDDATAFILES;修改表空间大小alterdatabasedatafile'/path/NADD......
  • Oracle正则表达式函数
    1、正则表达式中的元字符元字符意思例子\说明要匹配的字符是一个特殊字符、常量或者后者引用。(后引用重复上一次的匹配)\n匹配换行符\\匹配\\(匹配(\)匹配)^匹配字符串的开头位置如果A是字符串的第一个字符,^A匹配A$匹配字符串的末尾位置如果B是字符......
  • Oracle的差异增量备份和累积增量备份
    在rman增量备份中,有差异增量和累积增量的概念   1、概念    差异增量:是备份上级及同级备份以来所有变化的数据块,差异增量是默认增量备份方式    累积增量:是备份上级备份以来所有变化的块   因为累积增量是备份上级备份以来所有变化的数据块,所以累积增量需要更......
  • Java 的值传递与引用传递
     实参与形参我们都知道,在Java中定义方法的时候是可以定义参数的。比如Java中的main方法,publicstaticvoidmain(String[]args),这里面的args就是参数。参数在程序语言中分为形式参数和实际参数。形式参数:是在定义函数名和函数体的时候使用的参数,目的是用来接收调用该函数时......
  • 知识库系统推荐,强大的全文检索与文档分类管理功能
    在我们日常企业运营管理过程中,会积累大量的文档资料,对于我们全体成员来说,这些知识文档都是巨大的财富,所以整合并搭建一套知识库系统是非常有必要的。 知识库系统推荐我们日常工作中产生大量的文档,随着存储技术的进步,使得存储文件的成本越来越低。最终,几乎所有的文档,都被积累下来。......
  • C++ 左/右值及其引用 论述
    说明:本文探讨的是C++11以来的值类别关于左值和右值,在不对其进行详细的划分时,简单的分类方法包括左值持久,右值短暂能取得地址得通常是左值,反之通常是右值(这一方法启示我们一个表达式的类型与其是左值还是右值无关,即相同类型的表达式既可以是左值也可以是右值)右......
  • oracle数据库中查看表空间下各表占用表空间的大小
    背景:在做数据库巡检时,检查大表是必不可少的操作,可以查看各表占用表空间的大小,下面直接上例子,然后表空间名字我写成实际的了selectt.owner,t.segment_name,t.tablespace_name,bytes/1024/1024/1024assizes,q.num_rows,t.segment_typefromdba_segmentstleftjoindba_tablesq......