CodeClimber
CodeClimber

Reputation: 4664

Add new field to SOLR with default value. Populate existing documents

I have added a new field to a SOLR 3.6.1 schema.xml with a default value. Is it possible to populate / index existing documents in the SOLR repository with this default value without having to re-load all the data? I have been looking at re-indexing and re-optimizing but haven't been able to get this to work?

Upvotes: 2

Views: 2341

Answers (2)

JeffersonZhang
JeffersonZhang

Reputation: 239

Check Solr: Add new fields with Default Value for Existing Documents

If we only need search and display the new fields, we can do the following steps.

  1. add the new field definition in schema.xml:

  2. We need update search query: when search default value for this newFiled, also search null value: -(-newFiled:defaultValue AND newFiled:[* TO *])

  3. Use DocTransformer to add default value when there is no value in that field for old data.

Some functions may not work such as sort, stats.

Upvotes: 1

Jayendra
Jayendra

Reputation: 52779

Any changes in schema.xml related to addition or change in fields would need re-indexing of the data.
So you have to reload your data.

If you know the document, you can do a Partial update of all those document with just that field.

Upvotes: 1

Related Questions