1

我正在使用 Oracle 11g 和 Oracle Text 作为 Web 搜索引擎。

我现在已经创建了一个Keywords包含空格分隔的单词的 CLOB 列并对其进行了文本索引。这允许我扩展搜索,因为 Oracle Text 将返回在该列中存储了一个或多个关键字的行。该列的内容对用户隐藏,仅用于“扩展”搜索。这是按预期工作的。

但是现在我需要支持多个单词甚至完整的句子。在当前配置下,Oracle Text 将仅搜索单个关键字。我如何需要存储短语并配置 Oracle Text 以便它搜索整个短语(精确匹配是首选,但模糊匹配也可以)?

两行的列内容示例(分号分隔值):

"hello, hello; is there anybody out there?; nope;"
"just the; basic facts;"

我发现了一个类似的问题:Searching a column with comma separator values,但我需要一个具有自由文本搜索功能的 Oracle 11g 解决方案。

可能的解决方案:

第一个解决方案:我正在考虑重新设计数据库,如下所示。我会做一张新桌子Keywords(pkID NUMBER, nonUniqueID NUMBER, singlePhrase VARCHAR2(100 BYTE))。我会将上一列更改KeywordKeywordNonUniqueID,它将保存 ID(而不是值列表)。在搜索时,我会与新Keyword表进行 INNER JOIN。这个解决方案的问题是我会得到多行,其中包含除了短语之外的相同数据。我认为这会破坏排名?

第二种解决方案:是否可以将短语作为 XML 存储在原始Keyword列中,并以某种方式告诉 Oracle Text 在 XML 中搜索?

第三种解决方案:?

请注意,通常不会有很多短语(少于 100 个),也不会很长(单个短语最多有 5 个单词)。

另请注意,我目前正在使用CONTAINS及其一些运算符来满足我的全文搜索需求。

编辑:这个https://forums.oracle.com/forums/thread.jspa?messageID=10791361讨​​论几乎解决了我的问题,但它也匹配单个单词,而不是整个短语(精确匹配)。

4

1 回答 1

1

Oracle supports searching of phrases by default. In docs we can see this

4.1.4.1 CONTAINS Phrase Queries

If multiple words are contained in a query expression, separated only by blank spaces (no operators), the string of words is considered a phrase and Oracle Text searches for the entire string during a query.

For example, to find all documents that contain the phrase international law, enter your query with the phrase international law.

Did I answer your question or misunderstand you?

P.S. It seems to me that the solution is convert

"hello, hello; is there anybody out there?; nope;" "just the; basic facts;"

to

"hello, hello aa is there anybody out there? aa nope aa" "just the aa basic facts aa"

and search with CONTAINS for the phrase "is there anybody out there? aa"

于 2013-01-17T13:17:39.823 回答