sunspot solr未定义的字段类型

发布于 2024-11-30 08:02:45 字数 576 浏览 1 评论 0原文

我的太阳黑子和 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

淡淡の花香 2024-12-07 08:02:45

听起来您的生产 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 standard schema.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 that type is undefined is what implies to me that you're using a schema.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.

∞觅青森が 2024-12-07 08:02:45

对于 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

For 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:

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

It is recommended to create another core (my_core) from the solr web interface, copy schema.xml and solrconfig.xml to that folder and point path to /solr/my_core

虫児飞 2024-12-07 08:02:45

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

<field name="type" stored="true" type="string" multiValued="true" indexed="true" required="true" />

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.

<field name="type" stored="true" type="string" multiValued="true" indexed="true" required="true" />
遗弃M 2024-12-07 08:02:45

对我来说,它在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文