Sql Oracle--意外包含结果
数据库信息:Sql Oracle--意外包含结果,sql,oracle,oracle11g,Sql,Oracle,Oracle11g,数据库信息: 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 设置: CREA
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
对于第二条记录(C_result==0),这是一个好结果吗?我不知道发生了什么事
好的部分来了。将名称更改为不同的名称,如Willie
更改为Billie
和Will
更改为Bill
,查询:
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
因此,改变一个位置会使其工作方式不同。我不知道那是怎么回事。任何解决这个问题的方法都很好。一个单词
将
列在英语语言的默认停止列表中,默认情况下它不会被索引。请参阅此链接:
创建您自己的停止列表并在索引中使用它,请尝试以下代码(您必须已在ctx_dll上授予执行权限):
单词
将
列在英语语言的默认停止列表中,默认情况下不编制索引。请参阅此链接:
创建您自己的停止列表并在索引中使用它,请尝试以下代码(您必须已在ctx_dll上授予执行权限):
drop index ind_contains_test;
exec CTX_DDL.CREATE_STOPLIST('my_empty_stoplist','BASIC_STOPLIST');
create index ind_contains_test on my_contains_test(search)
indextype is ctxsys.context parameters('stoplist my_empty_stoplist');
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 4