我在一列上使用 ctxsys.context 索引来促进 Oracle Text 全文搜索功能。但是在索引由“,”或“。”分隔的数值时会出现问题。
我创建了如下索引:
create index my_index on my_table(my_column)
indextype is ctxsys.context parameters ('SYNC (ON COMMIT)');
然后我插入四个文本文档:
insert into my_table (id, doc) values (1, 'FOO 300 BAR');
insert into my_table (id, doc) values (2, 'FOO 300 BAR 1,000.00');
insert into my_table (id, doc) values (3, 'FOO1FOO');
insert into my_table (id, doc) values (4, '1 FOO');
现在我想使用 contains 运算符搜索“FOO 300 BAR”、“1,000.00”以及两者的组合:
select score(1), id from my_table where contains(doc, 'FOO 300 BAR', 1) > 0;
select score(1), id from my_table where contains(doc, '1,000.00', 1) > 0;
select score(1), id from my_table where contains(doc, 'FOO 300 BAR 1,000.00', 1) > 0;
第一个按预期工作,结果我得到了 id 1 和 2。虽然当我尝试使用 1,000.00 时,结果是 0 行。
正如我从文档中看到的那样,它默认使用 BASIC_LEXER。我还尝试在词法分析器上明确指定分隔符并将其应用于索引。
begin
ctx_ddl.create_preference('my_lex', 'BASIC_LEXER');
ctx_ddl.set_attribute('my_lex', 'numjoin', '.');
ctx_ddl.set_attribute('my_lex', 'numgroup', ',');
end;
create index my_index on my_table(doc)
indextype is ctxsys.context parameters ('SYNC (ON COMMIT) LEXER my_lex');
但是我经历了与以前相同的行为。
有人可以解释一下 Oracle Text 如何处理带有分隔符的数字,以及我如何配置索引以便将分隔的数字视为单个单词?
我正在使用 Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production