【发布时间】:2012-04-02 10:55:07
【问题描述】:
我正在使用 Solr 3.5.0 和 jetty-6.1-SNAPSHOT 下的示例服务器。我从默认的 schema.xml 开始,删除了默认的 <field> 定义,并指定了我自己的定义,包括这些:
<field name="content" type="text_general" indexed="false" stored="false" required="true" />**
<field name="title" type="text_general" indexed="false" stored="true" required="true" />
<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
我已将 content 字段的索引设置为 false,因为我稍后会尝试在模式中的 copyField 定义中使用此字段。而且我已将设置存储为 false,因为我不需要在查询结果中看到这个 content 字段。
稍后在架构中,我定义了这些 copyFields:
<copyField source="title" dest="text"/>
<copyField source="content" dest="text"/>
这是我的数据示例:
<add>
<doc>
<field name="id">2-29-56</field>
<field name="title">This is a test</field>
<field name="content">This is some content</field>
</doc>
</add>
我使用以下模式运行示例 Solr 服务器:
C:\solr\example>java -jar start.jar
然后我尝试将此示例文档发送到我的 Solr 服务器:
C:\solr\example\exampledocs>java -jar post.jar test.xml
这是我回来的:
SimplePostTool: version 1.4
SimplePostTool: POSTing files to http://localhost:8983/solr/update..
SimplePostTool: POSTing file test.xml
SimplePostTool: FATAL: Solr returned an error #400 [doc=2-29-56] missing required field: content
我尝试了许多不同的方法,但如果我更改架构以便为content 字段定义设置 indexed="true",它就可以工作。或者,如果我将其设置为 false 并设置 stored="true",那么它也可以工作。如果 indexed AND stored 设置为 false,它总是会失败。
如果我没有定义一个使用 content 字段的 copyField,这会有点道理。示例模式 cmets 甚至状态:
"为获得最佳索引大小和搜索性能,请将 "index" 设置为 false 对于所有常规文本字段,使用 copyField 将它们复制到 包罗万象的“文本”字段,并将其用于搜索。”
那么正确的方法是什么,最有效的方法是什么?
【问题讨论】:
标签: solr