我在使用 JRuby 和 Sunspot 在 Rails 中建立索引时遇到问题。我有一个包含参考数据的附加数据库,以及与其中一个表关联的模型。这就是我的 database.yml 的样子:
# regular stuff
# ...
# reference database
snomed:
adapter: jdbcmysql
encoding: utf8
hostname: localhost
database: snomedct
username: user
password: pass
socket: /tmp/mysql.sock
pool: 5
timeout: 5000
这就是我对该数据库的模型的样子:
class SnomedMaster < ActiveRecord::Base
establish_connection "snomed"
self.table_name = "curr_description_f"
attr_accessible :effectivetime, :active, :moduleid, :conceptid, :languagecode, :typeid, :term, :casesignificanceid
searchable do
text :term
end
end
但是,当我尝试通过在 rails 控制台中运行SnomedMaster.index或rake sunspot:reindex来索引字段时,它不起作用。问题似乎在这里(来自跟踪日志):
SELECT `curr_description_f`.* FROM `curr_description_f` WHERE (`curr_description_f`.`` >= 0) ORDER BY `curr_description_f`.`` ASC LIMIT 50
ActiveRecord::JDBCError: Unknown column 'curr_description_f.' in 'where clause': SELECT `curr_description_f`.* FROM `curr_description_f` WHERE (`curr_description_f`.`` >= 0) ORDER BY `curr_description_f`.`` ASC LIMIT 50
我不知道太阳黑子为什么要访问列 *curr_description_f*...
谢谢