データベース情報:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
"CORE 11.2.0.3.0 Production"
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
設定:
CREATE TABLE my_contains_test(
USERID VARCHAR2(8) NOT NULL,
SEARCH VARCHAR2(40),
CONSTRAINT contains_test_pk PRIMARY KEY (USERID)
);
INSERT ALL
INTO my_contains_test VALUES ('HUNTERW','Willie Hunter')
INTO my_contains_test VALUES ('HUWU','Will Hu')
SELECT * FROM dual;
create index ind_contains_test on my_contains_test(search) indextype is ctxsys.context;
クエリ:
select m.*, contains(search, 'will% and hu%', 1) as c_result from my_contains_test m;
結果:
USERID SEARCH C_RESULT
HUNTERW Willie Hunter 4
HUWU Will Hu 0
それは 2 番目のレコード (C_RESULT == 0) の良い結果ですか? 何が起こっているのかわかりません。
ここに良い部分があります。Willie
toBillie
やWill
to Bill
、query toのように、名前を別のものに変更します。
select m.*, contains(search, 'bill% and hu%', 1) as c_result from my_contains_test m;
そして結果は正しいです:
USERID SEARCH C_RESULT
HUNTERW Billie Hunter 4
HUWU Bill Hu 4
したがって、1 つの位置を変更すると、動作が異なります。一体何のことだかさっぱりわからない。それを解決する方法についてのアイデアは素晴らしいでしょう。