我正在尝试使用pysolr将文档添加到Solr (5.3.2)中。我生成了一个简单的JSON对象,其中包含一个大文本和一些元数据(日期、作者...)然后我尝试将其添加到Solr中。我的问题是,超过一定的大小,Solr将无法对文档进行索引,并返回以下错误:
Solr responded with an error (HTTP 400): [Reason: Exception writing document id e2699f18-ab5f-47f6-a450-60db5621879c to the index; possible analysis error.]字段长度似乎真的有一个硬编码的限制,但我找不到它。
通过使用python,我发现:
default_obj['content'] = content[:13260]将工作得很好,同时
default_obj['content'] = content[:13261]将导致错误。
在我的schema.xml中,content字段被定义为一个普通的type="text_general“字段。
编辑:这里是schema.xml的定义
<field name="content" type="text_general" indexed="true" stored="true" multiValued="true"/>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>我尝试过通过Solr的web管理界面手动添加内容,但遇到了完全相同的问题。
发布于 2017-10-12 21:07:17
您最有可能面临单令牌方面的硬限制,即等于32766。您不能更改这个限制,但是您可以更改行为,并使用一些Tokenizer将文档中的原始文本拆分为单独的标记。
例如,您可以尝试WhitespaceTokenizer,它将在多个术语/标记中分隔您的大字段,并且您的文档将被安全地索引。
https://stackoverflow.com/questions/46705866
复制相似问题