Oracle 中Contains 函数的用法

1. 查询住址在北京的学生

select student_id,student_name
from students
where contains( address, 'beijing' )

remark: beijing是一个单词,要用单引号括起来。

2. 查询住址在河北省的学生

select student_id,student_namefrom students
where contains( address, '"heibei province"' )

remark: hebei province是一个词组,在单引号里还要用双引号括起来。

3. 查询住址在河北省或北京的学生

select student_id,student_namefrom students
where contains( address, '"heibei province" or beijing' )

remark: 可以指定逻辑操作符(包括 and ,and not,or )。

4. 查询有 ‘南京路’ 字样的地址

select student_id,student_name
from students
where contains( address, 'nanjing near road' )

remark: 上面的查询将返回包含 ‘nanjing road’,’nanjing east road’,’nanjing west road’ 等字样的地址。
          a near b,就表示条件: a 靠近 b。

5. 查询以 ‘湖’ 开头的地址

select student_id,student_name
from students
where contains( address, '"hu*"' )

remark: 上面的查询将返回包含 ‘hubei’,’hunan’ 等字样的地址。
          记住是 *,不是 %。

6. 类似加权的查询

select student_id,student_name
from students
where contains( address, 'isabout (city weight (.8), county wright (.4))' )

remark: isabout 是这种查询的关键字,weight 指定了一个介于 0~1之间的数,类似系数(我的理解)。表示不同条件有不同的侧重。

7. 单词的多态查询

select student_id,student_name
from students
where contains( address, 'formsof (inflectional,street)' )

remark: 查询将返回包含 ‘street’,’streets’等字样的地址。
        对于动词将返回它的不同的时态,如:dry,将返回 dry,dried,drying 等等。

8. 词查询示例

  词查询是对输入到 contains 运算符中单引号间的精确单词或短语的查询。在以下示例中,我们将查找文本列中包含 oracle 一词的所有文档。每行的分值由使用标签 1 的 score 运算符选定:

select score(1) title from news where contains(text,'oracle',1)> 0;

  在查询表达式中,可以使用 and 和 or 等文本运算符来获取不同结果。还可以将结构性谓词添加到 where 子句中。可以使用 count(*)、ctx_query.count_hits 或 ctx_query.explain 来计算查询的命中 (匹配) 数目。

9 about查询示例

  在所有语言中,about查询增加了某查询所返回的相关文档的数目。在英语中,about 查询可以使用索引的主题词组件,该组件在默认情况下创建。这样,运算符将根据查询的概念返回文档,而不是仅依据所指定的精确单词或短语。例如,以下查询将查找文本列中关于主题 politics 的所有文档,而不是仅包含 politics 一词的文档: 

select score(1) title from news where contains(text, 'about(politics)', 1) > 0;

总结

以上所述是www.887551.com给大家介绍的oracle 中contains 函数的用法,希望对大家有所帮助

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐