1

在 Rails gem oracle-enhanced 的文档中,我发现这是在多个表上创建索引:

add_context_index :posts,
[:title, :body,
 "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
],
:name => 'post_and_comments_index',
:index_column => :all_text,
:index_column_trigger_on => [:updated_at, :comments_count],
:sync => 'ON COMMIT'

如果帖子有很多评论,则此方法有效。但是如果一篇文章只有一条评论(belongs_to),我该怎么写呢?或者 has_many 槽关系呢?

谢谢你的帮助。

-e- 只是为了尝试一下我所做的

add_context_index :posts, [:title, :body]

并得到了这个例外:

NativeException: java.sql.SQLException: ORA-06550: line 2, column 13:
PLS-00201: identifier 'CTX_DDL' must be declared
4

1 回答 1

0

我决定独立索引每一列,分别在每个表中搜索并将匹配的 id 复制到临时查找表中,而不是在多个表上执行一个索引来进行搜索。这是非常简单和快速的。

于 2014-03-17T09:18:24.477 回答