-->

400 Bad Request: unknown field 'type'

2019-03-28 04:38发布

问题:

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.



标签: solr sunspot