[英]JRuby on Rails and Solr indexing
I am having trouble with indexing in Rails with JRuby and Sunspot. 我在使用JRuby和Sunspot在Rails中建立索引时遇到麻烦。 I have an additional database that contains reference data, and a model associated with one of the tables.
我还有一个包含参考数据的附加数据库,以及一个与表之一相关联的模型。 This is what my database.yml looks like:
这是我的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
And this is what my model for that database looks like: 这就是我针对该数据库的模型:
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
However, when I try to index the fields by running SnomedMaster.index in rails console or rake sunspot:reindex , it does not work. 但是,当我尝试通过在Rails控制台中运行SnomedMaster.index或rake sunspot :reindex来索引字段时,它不起作用。 The problem seems to be here (from the trace log):
问题似乎在这里(来自跟踪日志):
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
I don't know why sunspot wants to access column *curr_description_f*... 我不知道黑子为什么要访问* curr_description_f *列...
Thanks 谢谢
Solved it on my own. 我自己解决了。 The WHERE clause wants to call:
WHERE子句想调用:
WHERE (`curr_description_f`.`id` >= 0)
Basically, because of the malformed sqldump, my database had a string id for primary key, and the key wasn't even assigned to my model. 基本上,由于sqldump格式错误,我的数据库有一个主键的字符串ID,并且甚至没有将键分配给我的模型。 That's why it was empty.
这就是为什么它是空的。 So I re-created the tables with INT as a primary key, and then added an additional line to my model:
因此,我以INT作为主键重新创建了表,然后在模型中添加了另一行:
self.primary_key = "id"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.