sunspot solr未定义的字段类型
我的太阳黑子和 solr 有问题。在开发中,它的工作方式像魅力,但在生产中,我从 Rails 生产日志中得到以下错误:
RSolr::RequestError (Solr Response: undefined field type): app/controllers/search_controller.rb:7:in `index'
我猜它与 schema.xml 有关。但我对 solr 还很陌生。那么有人可以帮助我吗?
好的:
控制器
def index
unless params[:q].blank?
@search = Question.search do
fulltext params[:q]
end
@results = @search.results
else
@results = nil
end
@searchterm = params[:q]
端
模型(问题)
...
searchable do
text :title
text :content
end
I'm having a problem with my sunspot and solr. In development it worked like charme but in production I get the following error out of my rails production log:
RSolr::RequestError (Solr Response: undefined field type):
app/controllers/search_controller.rb:7:in `index'
I guess it has something to do with the schema.xml. But I'm quite new to solr. So can anybody help me?
OK:
Controller
def index
unless params[:q].blank?
@search = Question.search do
fulltext params[:q]
end
@results = @search.results
else
@results = nil
end
@searchterm = params[:q]
end
model (Question)
...
searchable do
text :title
text :content
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来您的生产 Solr 实例没有使用 Sunspot 的
schema.xml
。type
字段应在 Sunspot 的标准schema.xml
中定义,它用于索引对象的模型名称,以便稍后在过滤搜索时使用。看到一条错误消息说type
未定义,这对我来说意味着您正在使用 Sunspot 以外的schema.xml
。您可能正在使用用于在服务器上安装 Solr 的方法中的其他一些示例或默认配置集。如果可以的话,请详细说明如何设置生产 Solr 服务器。
It sounds like your production Solr instance is not using Sunspot's
schema.xml
.The
type
field should defined in Sunspot's standardschema.xml
, and it is used to index the model name of the object, for later use in filtering your searches. Seeing an error message saying thattype
is undefined is what implies to me that you're using aschema.xml
other than Sunspot's.It could be that you're using some other sample or default set of configurations from the method you used to install Solr on your server. If you can, please elaborate on how you set up your production Solr server.
对于 Solr 4.7,将 schema.xml 和 solrconfig.xml 从 your_app/solr/conf 复制到 /opt/solr/solr/collection1 (或任何 solr 路径),如果仍然不起作用,请确保您的 config/sunspot.yml类似于:
建议从 solr Web 界面创建另一个核心 (my_core),复制
schema.xml
并solrconfig.xml
到该文件夹并将路径指向 /solr/my_coreFor Solr 4.7, copy schema.xml and solrconfig.xml from your_app/solr/conf to /opt/solr/solr/collection1 (or whatever your solr path is) and if still not working, make sure that your config/sunspot.yml is something like:
It is recommended to create another core (my_core) from the solr web interface, copy
schema.xml
andsolrconfig.xml
to that folder and point path to /solr/my_core确保在 schema.xml 中将字段类型设置为 required="true",否则重新索引将不会在索引数据中包含字段“type”。
Make sure to set the field type to required="true" in your schema.xml or reindexing will not include the field "type" in your indexed data.
对我来说,它在 Heroku 插件 Websolr 仪表板中,默认配置设置为黑光,我必须将其更改为太阳黑子。
For me it was in Heroku addon Websolr dashboard, the default configuration was set to blacklight, and I had to change it to sunspot.