繁体   English   中英

Solr:缺少字段时出现“缺少必填字段”错误?

[英]Solr: “missing required field” error when the field is not missing?

我在Jetty-6.1-SNAPSHOT下的示例服务器中使用了Solr 3.5.0。 我从默认的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”,那么它也可以工作。 如果将“索引”和“存储”设置为false,则始终失败。

如果我没有定义使用content字段的copyField,这将很有意义。 示例模式注释甚至声明:

“为了获得最佳的索引大小和搜索性能,请将所有常规文本字段的“ index”设置为false,使用copyField将其复制到全部“ text”字段,然后将其用于搜索。

那么,最有效的方法是什么?

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM