2

我的太阳黑子和 solr 有问题。在开发中它像魅力一样工作,但在生产中我从我的 Rails 生产日志中得到以下错误:

RSolr::RequestError(Solr 响应:未定义的字段类型):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
4

4 回答 4

6

听起来您的生产 Solr 实例没有使用 Sunspot 的schema.xml.

type字段应在 Sunspot 的标准中定义,schema.xml用于索引对象的模型名称,以供以后过滤搜索使用。看到一条错误消息说type未定义,这对我来说意味着您使用的schema.xml不是 Sunspot 的。

可能是您正在使用您在服务器上安装 Solr 的方法中的一些其他示例或默认配置集。如果可以,请详细说明如何设置生产 Solr 服务器。

于 2011-08-19T07:27:58.273 回答
3

对于 Solr 4.7,将 schema.xml 和 solrconfig.xml 从 your_app/solr/conf 复制到 /opt/solr/solr/collection1(或任何您的 solr 路径),如果仍然无法正常工作,请确保您的 config/sunspot.yml是这样的:

production:
  solr:
    hostname: localhost
    port: 8983
    log_level: WARNING
    path: /solr/collection1
    # read_timeout: 2
    # open_timeout: 0.5

建议从 solr Web 界面创建另一个核心 (my_core),复制schema.xmlsolrconfig.xml到该文件夹​​并指向 /solr/my_core 的路径

于 2014-07-04T21:42:56.517 回答
1

确保在 schema.xml 中将字段类型设置为 required="true",否则重新索引将不会在索引数据中包含字段“type”。

<field name="type" stored="true" type="string" multiValued="true" indexed="true" required="true" />
于 2013-12-09T17:42:04.700 回答
1

对我来说,它在 Heroku 插件 Websolr 仪表板中,默认配置设置为 blacklight,我不得不将其更改为 sunspot。

于 2017-03-30T14:19:39.417 回答