1

我正在创建一个需要在文本文件(.doc、.txt、.pdf、...)中搜索的数据库。开始创建首选项:

ctx_ddl.create_preference('DOCSPIDER_DIR','FILE_DATASTORE');

我没有分配“路径”值,因为可能有子目录。然后我创建一个表:

create table document (id number, path varchar2(2000));
ALTER TABLE document ADD (CONSTRAINT document_pk PRIMARY KEY (ID));

创建索引:

create index document_index on document(path)
indextype is ctxsys.context
parameters ('datastore DOCSPIDER_DIR filter ctxsys.auto_filter');

以及要同步的命令:

ctx_ddl.sync_index('document_index', '2M');

创建结构后,我插入一条记录,指向现有文档:

INSERT INTO document VALUES (1, '\\server\oracle_text_files\file_name.txt');

但是,当您运行查询以搜索此文档的内容时,它不会返回数据:

SELECT * from document WHERE CONTAINS(path, 'test', 1) > 0;

有什么东西不见了?

4

1 回答 1

0

我敢打赌,如果你去,你会得到结果:

SELECT * from document WHERE CONTAINS(path, 'txt', 1) > 0;

实际上,INSERT不会将文件加载到数据库中! 您必须查看某些内容以将文件加载为 CLOB 或其他内容。

SO上有一些有趣的帖子可以做同样的事情,比如说

于 2017-09-04T13:15:27.563 回答