2012-03-16 94 views
1

我在jetty-6.1-SNAPSHOT下使用示例服务器的Solr 3.5.0。我已经开始用默认schema.xml中,删除默认<field>定义,并指定我自己的,其中包括:Solr:字段没有丢失时“缺少必填字段”错误?

<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"/> 

我已经进行索引设置为false,content场,因为我想使用这个字段在模式中稍后的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字段定义,它的工作原理。或者,如果我把它放回false并设置stored =“true”,那么它也可以。如果索引和存储设置为false,它总是失败。

如果我没有定义使用内容字段的copyField,这将会有意义。样本模式的意见,即使状态:

“最佳索引大小和搜索性能,设置‘索引’为假 所有一般的文本字段,请使用copyField将其复制到 包罗万象的‘文本’字段,使用它进行搜索。“

那么最有效的方法是做正确的方法是什么?

回答

4

必填字段必须标记为索引或存储。
您可以删除这两个字段的必需属性,并将索引和存储都设为false。

由于文本字段只能被搜索,所以您可以将字段类型设置为普通字符串,而不对其他字段进行任何分析。

+0

有道理,谢谢! – 2012-03-17 16:42:48