为现有的Solr文档添加新字段而无需重新索引,可以通过以下步骤实现:
<fields>
标签,添加一个新的<field>
标签来定义新字段的名称、类型和其他属性。例如:<field name="new_field" type="text_general" indexed="true" stored="true"/>
这里的new_field
是新字段的名称,text_general
是字段的类型,indexed
和stored
属性分别表示该字段是否需要被索引和存储。
curl http://localhost:8983/solr/<collection>/update?commit=true -d '
[
{
"id": "document_id",
"new_field": "new_field_value"
}
]'
这里的<collection>
是Solr的集合名称,document_id
是要更新的文档的唯一标识符,new_field_value
是新字段的值。
curl http://localhost:8983/solr/<collection>/update?commit=true
这将提交之前的更新,并使新字段可用。
通过以上步骤,您可以为现有的Solr文档添加新字段而无需重新索引。请注意,这种方法只适用于添加新字段,如果需要对已有字段进行更改或删除,则可能需要重新索引。
没有搜到相关的文章