【问题标题】:Oracle Fuzzy Search with spaces带空格的 Oracle 模糊搜索
【发布时间】:2021-02-04 09:02:33
【问题描述】:

我想在 Oracle 中进行模糊搜索,但查询不适用于空格。

例如。假设我们有一个表 po_test_tmp 有很多记录

如果我们执行这个查询,它就可以正常工作

select score(1), ae.po_number
from po_test_tmp ae
where CONTAINS(po_number, 'fuzzy(po, 50,5000, weight)', 1)> 0
order by score(1) desc;

但是,如果我们尝试搜索 PO 123 之类的词,则它不起作用

select score(1), ae.po_number
from po_test_tmp ae
where CONTAINS(po_number, 'fuzzy(PO 123, 50,5000, weight)', 1)> 0
order by score(1) desc;
ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50901: text query parser syntax error on line 1, column 10  
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.

如果搜索词有空格,如何进行模糊搜索,搜索词可以有特殊字符和多个空格。

【问题讨论】:

    标签: oracle oracle11g oracle-sqldeveloper fuzzy-search fuzzy-logic


    【解决方案1】:

    首先请查看Fuzzy运营商的文档

    参数term - 指定执行模糊扩展的单词。

    请注意,词条通常不包含空白,您必须将搜索拆分为相关词条。

    另外注意fuzzy要被激活,这个词必须有至少3个字符。因此,您使用 PO 的示例将不起作用。

    您可以为您的设置做的是为您的模糊字符串的每个部分定义一个额外的fuzzy 搜索并将它们与near operator 结合起来,如下所示

     contains(po_number,'near (( fuzzy(word1,,,weight),fuzzy(word2,,,weight) ), 2, TRUE)',1) > 0
    

    near 在此强制要求两个匹配项必须相邻 (span = 2) 且有序 (TRUE)。

    特殊字符的处理取决于您首选项中whitespace和printjoins的定义。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多