【发布时间】:2012-03-03 23:53:24
【问题描述】:
我有这个问题:
select id from mytable where contains(all_text,'('||?||' within name)*2,
('||?||' within description)',1)>0
where 子句中的 contains 是如何工作的?
谢谢,
【问题讨论】:
标签: oracle
我有这个问题:
select id from mytable where contains(all_text,'('||?||' within name)*2,
('||?||' within description)',1)>0
where 子句中的 contains 是如何工作的?
谢谢,
【问题讨论】:
标签: oracle
如果第一个参数出现在名称部分,则其权重是第二个参数出现在描述部分的权重的两倍。
这个“包含”运算符将设置分数变量。没有它,重量加倍对于“>0”条件没有任何意义。然而,
SELECT id FROM mytable WHERE CONTAINS(all_text,'('||?||' WITHIN name)*2,
('||?||' WITHIN description)',1)>0 ORDER BY SCORE(1) DESC
完全有道理,并且会按照在名称部分中找到搜索词的那些行对 id 进行排序。
这是一个有用的参考,以防万一:http://docs.oracle.com/cd/B19306_01/text.102/b14218/cqoper.htm
【讨论】: