Oracle Text
Oracle Textでファイルを検索する場合の手段
-- プリファレンス作成 begin ctx_ddl.create_preference('mypref', 'FILE_DATASTORE'); ctx_ddl.set_attribute('mypref', 'PATH', '/home/oracle/filedir'); end; / -- テーブルの作成 create table hdocs ( id number primary key, -- pk fmt varchar2(10), -- ファイルフォーマット text varchar2(80) -- ファイルパス ); -- fmt列がbinary->バイナリファイル,text->テキストファイル ignore->索引作成対象外 insert into hdocs values(1, 'binary', '/home/oracle/filedir/001.doc'); insert into hdocs values (2, 'text', '/home/oracle/filedir/002.txt'); insert into hdocs values (3, 'binary', '/home/oracle/filedir/003.xls'); -- indexの作成 -- binaryとtextが同居している場合 create index hdocsx on hdocs(text) indextype is ctxsys.context parameters ('datastore ctxsys.file_datastore filter ctxsys.auto_filter format column fmt'); -- binaryのみ create index hdocsx2 on hdocs(text) indextype is ctxsys.context parameters ('datastore ctxsys.file_datastore filter ctxsys.auto_filter'); SQL> select * from hdocs where contains(text,'機能') > 0; ID FMT TEXT ---------- ------------------------------ ------------------------------------ 1 binary /home/oracle/filedir/001.doc
【備考】
パスワード保護されているファイルについては検索できないみたいだ。
【参考】
Oracle Textアプリケーション開発者ガイド 3 Oracle Textでの索引付け
http://otndnld.oracle.co.jp/document/products/oracle10g/102/doc_cd/text.102/B19213-01/ind.htm#i1007026