将 Solr 复制字段复制到另一个字段




我有以下配置:

...
<field name="spellcheck" type="text_spell" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_de" type="text_spell_de" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_en" type="text_spell_en" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_fr" type="text_spell_fr" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_ja" type="text_spell" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_zh" type="text_spell" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_pt" type="text_spell_pt" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_it" type="text_spell_it" indexed="true" stored="true" multiValued="true" />
<field name="spellcheck_low" type="text_spell" indexed="true" stored="true" multiValued="true" />
<field name="spellchecksearch" type="text_spell_en" indexed="true" stored="false" multiValued="true" />
<copyField source="spellcheck_en" dest="spellcheck_low" />
<copyField source="spellcheck_low" dest="spellchecksearch" />
...

spellcheck_en字段已经填充,并且它被正确复制到spellcheck_low字段中并且它正在正确索引(使用 luke 索引查看器,我看到字段的索引不为空(。但是,spellcheck_low的副本似乎不起作用,因为拼写检查搜索为空。注意:spellcheck_enspellcheck_low字段都被索引和存储,而拼写检查搜索不存储,而只索引.

为什么会这样?您可以澄清现场副本的工作原理,非常感谢:)

copyField指令不会作为图形进行评估 - 最初为source字段提交的值也用于填充作为dest给出的字段。

由于没有为 spellcheck_low 字段提交任何值,因此copyField指令最终会复制一个空值(.. 或根本不执行(。

在您的情况下,spellcheck_en字段必须有两个目标:

<copyField source="spellcheck_en" dest="spellcheck_low" />
<copyField source="spellcheck_en" dest="spellchecksearch" />

这将与您尝试实现的相同,因为任何复制操作都将在任何处理或索引发生之前发生(更新处理器 IIRC 除外(。

拼写检查搜索为空,因为它未存储。当字段被索引但未存储时,它只能用于搜索,但它的值仍然为空。并且它不会在值中返回。 有关详细信息,您可以阅读- 溶胶指数与存储

我认为如果您将字段拼写检查搜索索引并存储,您的问题将得到解决。

最新更新