【问题标题】:SOLR 4.10.2 - Add field with default valueSOLR 4.10.2 - 添加具有默认值的字段
【发布时间】:2021-07-21 20:10:50
【问题描述】:

我有一个 SOLR Core 4.10.2

我想为核心中的所有行添加一个索引 IDX_VehicalType 的字段 VehicalType,默认值为“car”。 - 我希望这个字段填充“汽车”

我已经能够使用 schema.xml 中的以下内容成功添加字段和索引并从 Core Admin 重新加载核心:

<field name="IDX_VehicleType" type="text_Exact" indexed="true" stored="false" multiValued="true"/>
<field name="VehicleType" type="string" indexed="true" stored="true"/>
<copyField source="VehicleType" dest="IDX_VehicleType"/>

当我尝试使用默认属性为该字段设置默认值 - 并重新加载并从 Core Admin 优化核心时,该字段未填充。

<field name="IDX_VehicleType" type="text_Exact" indexed="true" stored="false" multiValued="true" default="car"/>
<field name="VehicleType" type="string" indexed="true" stored="true" default="car"/>
<copyField source="VehicleType" dest="IDX_VehicleType"/>

我在架构浏览器中看到了该字段,但它没有显示在结果中。

【问题讨论】:

  • 您是否重新索引您的文档?默认值在索引时应用 AFAIK。
  • @GaëlJ 我去了Core Admin,选择了核心,然后点击了重新加载,然后点击了优化(我认为优化重新索引)-还有另一个重新索引命令吗?
  • Optimize 不会重新索引,它会优化当前索引。要重新索引,您别无选择,只能从初始数据源重新插入 Solr 中的所有文档。

标签: solr solr4


【解决方案1】:

此更改属于需要在 SOLR 中重新索引以反映字段中的值的更改类别。 重复一遍,如果我们想用索引中现有文档的默认值填充该字段,我们需要重新索引索引中的所有文档。

对于将来对索引的任何添加/更新,SOLR 将根据新架构自动设置默认字段值。

更多信息: https://solr.apache.org/guide/8_0/reindexing.html#changing-field-and-field-type-properties https://solr.apache.org/guide/8_0/defining-fields.html#field-properties

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-28
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多