400 Bad Request: unknown field 'type'

自闭症网瘾萝莉.ら 提交于 2019-12-09 11:43:04

问题


I've set up Solr 3.6.2 on Tomcat as described here.

Using the sunspot-rails gem and the embedded solr server I have no problems, but on my staging server I'm getting the response:

message ERROR: [doc=Foo 20] unknown field 'type'

description The request sent by the client was syntactically incorrect.

The request data looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<add>
  <doc>
    <field name="id">Foo 20</field>
    <field name="type">Foo</field>
    <field name="type">ActiveRecord::Base</field>
    <field name="class_name">Foo</field>
    <field name="name">test</field>
  </doc>
</add>

What's causing this? Is there some configuration that should be set? (I'm expecting something that allows for the type name to be used regardless of whether or not such a column exists.)


回答1:


It turns out that the sunspot-solr gem expects a slightly different schema.xml than the default that is bundled with solr.

I replaced the file with the one that the gem uses (from here) and it works fine now. This answer explains what the schema.xml file is.



来源:https://stackoverflow.com/questions/14700535/400-bad-request-unknown-field-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!