暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 包含带有 “not” 或 “no” 查询词的运算符不起作用

askTom 2017-10-16
234

问题描述

我有一个大的自由文本字段,我试图查询特定的事件。我有三个需要彼此靠近的查询词,所以我想使用contains near运算符。但其中一个查询词不是 “否” 就是 “否”。

当我尝试使用不,我得到这个错误...
  ORA-29902: error in executing ODCIIndexStart() routine
  ORA-20000: Oracle Text error:
  DRG-50901: text query parser syntax error on line 1, column 1  
  29902. 00000 -  "error in executing ODCIIndexStart() routine"
  *Cause:    The execution of ODCIIndexStart routine caused an error.
  *Action:   Examine the error messages produced by the indextype code and
           take appropriate action.
复制


我尝试过 “不”,它忽略了该查询项,并返回那些包含彼此附近的其他两个查询项的查询项。

当我尝试使用no时,它会再次忽略该查询项,并返回那些包含彼此附近的其他两个查询项的查询项。但是我没有像没有那样得到上述错误。

是否有理由 “否” 或 “不” 不能与contains运算符用作查询词?如果是这样,它周围是否有?

谢谢

专家解答

首先,no和not都在默认停止列表中。所以你必须使用一个自定义的停止列表,它排除了这些来索引它们。

完成此操作后,您需要转义要搜索的任何关键字。正如你所发现的,不是一个关键词。要解决这个问题,请在大括号之间插入:

create table t (
  x varchar2(10)
);
insert into t values ('this');
insert into t values ('that');
insert into t values ('not this');
commit;
exec ctx_ddl.create_stoplist('empty_stoplist');
create index i on t (x) indextype is ctxsys.context
  parameters ('stoplist empty_stoplist');

select * from t
where  contains (x, 'this') > 0;

X          
this       
not this 

select * from t
where  contains (x, 'not this') > 0;

ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50901: text query parser syntax error on line 1, column 1 

select * from t
where  contains (x, '{not} this') > 0;

X          
not this 

exec ctx_ddl.drop_stoplist('empty_stoplist');
复制

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论