今天,按照徐进挺之“Oracle全文检索”进行测试,发现Context类型索引对中文不能分词,结果如下:
Create table docs (id number primary key, text varchar2(200));
Insert into docs values(1, 'california is a state in the us.');
Insert into docs values(2, 'paris is a city in france.');
Insert into docs values(3, 'france is in europe.');
Commit;
/
--建立context 索引
Create index idx_docs on docs(text)
indextype is ctxsys.context parameters
('filter ctxsys.null_filter section group ctxsys.html_section_group');
--查询
Column text format a40;
Select id, text from docs where contains(text, 'france') > 0;
ID TEXT
---------- ----------------------------------------
2 paris is a city in france.
3 france is in europe.
--继续插入数据
Insert into docs values(4, 'los angeles is a city in california.');
Insert into docs values(5, 'mexico city is big.');
commit;
Select id, text from docs where contains(text, 'city') > 0;--新插入的数据没有查询到
ID TEXT
---------- ----------------------------------------
2 paris is a city in france.
--索引同步
exec ctx_ddl.sync_index('idx_docs', '2m');
Select id, text from docs where contains(text, 'city') > 0; --查到数据
ID TEXT
---------- ----------------------------------------------------------------------
2 paris is a city in france.
4 los angeles is a city in california.
5 mexico city is big.
Select id, text from docs where contains(text, 'city or state ') > 0;
ID TEXT
---------- ----------------------------------------------------------------------
1 california is a state in the us.
2 paris is a city in france.
4 los angeles is a city in california.
5 mexico city is big.
Select id, text from docs where contains(text, 'city and state ') > 0;
Select id, text from docs where contains(text, 'city state ') > 0;
ID TEXT
---------- ----------------------------------------------------------------------
SQL> Select SCORE(1),id, text from docs where contains(text, 'city or state',1) > 0;
SCORE(1) ID TEXT
---------- ---------- ----------------------------------------------------------------------
5 1 california is a state in the us.
4 2 paris is a city in france.
4 4 los angeles is a city in california.
4 5 mexico city is big.
--下面中文
Insert into docs values(14, '新华网东京4月12日电(记者蓝建中)日本经济产业省原子能安全保安院与日本原子能安全委员会12日上午举行联合新闻发布会,正式宣布根据国际核事件分级表,将福岛第一核电站事故的严重程度评价提高到最高级别7级。');
Insert into docs values(15, '原子能安全保安院宣布,福岛第一核电站向大气泄漏的放射性物质已达到37万万亿贝克勒尔,而原子能安全委员会推断为63万万亿贝克勒尔,虽然数值存在差异,但都已经远远超过核电站事故7级的标准。');
Insert into docs values(16, '国际核事件分级表规定,如果放射性物质向外部的泄漏量达到数万万亿贝克勒尔,就应定为7级。');
commit;
SQL> Select id, text from docs where contains(text, '原子能') > 0;
ID TEXT
---------- ----------------------------------------------------------------------
SQL> Select id, text from docs;
ID TEXT
---------- ----------------------------------------------------------------------
1 california is a state in the us.
2 paris is a city in france.
3 france is in europe.
4 los angeles is a city in california.
5 mexico city is big.
14 原子能安全保安院宣布,福岛第一核电站向大气泄漏的放射性物质已达到37万万
亿贝克勒尔,而原子能安全委员会推断为63万万亿贝克勒尔,虽然数值存在差异
,但都已经远远超过核电站事故7级的标准。');
15 原子能安全保安院宣布,福岛第一核电站向大气泄漏的放射性物质已达到37万万
亿贝克勒尔,而原子能安全委员会推断为63万万亿贝克勒尔,虽然数值存在差异
,但都已经远远超过核电站事故7级的标准。
16 国际核事件分级表规定,如果放射性物质向外部的泄漏量达到数万万亿贝克勒尔
,就应定为7级。
8 rows selected
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/81227/viewspace-692318/ ,如需转载,请注明出处,否则将追究法律责任。