在 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