我有一个Alfresco模型类型,具有类型的附加属性d:content.当我尝试在其中存储大于32 KB的内容时,此属性会导致Solr异常.该属性的当前定义是
<property name="acme:secondContent">
<type>d:content</type>
<mandatory>false</mandatory>
<index enabled="true">
<atomic>true</atomic>
<stored>true</stored>
<tokenised>both</tokenised>
</index>
</property>
Run Code Online (Sandbox Code Playgroud)
如果我将大于32 KB的内容放入此属性,Solr在尝试索引时会抛出此异常:
java.lang.IllegalArgumentException: Document contains at least one immense term in field="content@s____@{http://acme.com/model/custom/1.0}secondContent" (whose UTF8 encoding is longer than the max length 32766), all of which were skipped. Please correct the analyzer to not produce such terms.
Run Code Online (Sandbox Code Playgroud)
更改index配置没有帮助,index我尝试过的所有变体和子元素都会引发错误.
在另一个问题中回答:
底层Lucene索引中单个术语的最大大小为32776字节,我相信这是硬编码的.
如何配置index一个的d:content属性,以便我可以保存和索引的内容超过32 KB的?
编辑:
在contentModel.xml,cm:content配置如下:
<index enabled="true">
<atomic>true</atomic>
<stored>false</stored>
<tokenised>true</tokenised>
</index>
Run Code Online (Sandbox Code Playgroud)
添加text/plain内容大于32 KB 的简单文件可以正常工作.
index我的自定义属性的相同配置仍然失败.
更新:
在露天4.2fCE,究竟问题不会发生.所以这是Alfresco 5.0c和Solr 4.1.9中的一个错误.
更新2:
小智 5
假设1
如果您的内容包含类似的非常长的术语(长度为32k的单个单词),则必须实现自己的Lucene分析器以支持该特定类型的文本.这意味着它是与默认Lucene实现相关的问题,因为它是硬编码的.
假设2
否则,如果您的内容不是以上述方式构建的,那对我来说听起来很奇怪,可能就是一个bug.如果您没有使用tokenised = true进行求解,在这种情况下,可能的解决方法可能是基于更改内容模型以支持父节点与包含所涉及文本但使用默认cm的特定节点类型之间的关联:内容属性.我的意思是使用你应该解决的协会;)
希望这可以帮助.
解决方案不是将完整的文档/部分存储在索引中。因此,在大于 32k 的大型属性上,请尽量避免 store=true 和 tokenize=both/false。如果您的模型声明如下所示,则索引应该可以工作:
<property name="acme:secondContent">
<type>d:content</type>
<mandatory>false</mandatory>
<index enabled="true">
<atomic>true</atomic>
<stored>false</stored>
<tokenised>true</tokenised>
</index>
</property>
Run Code Online (Sandbox Code Playgroud)
缺点:在我的测试中我不得不删除整个索引。我不足以删除 solr 中的缓存模型