bpgergo
bpgergo

Reputation: 16037

Solr: how to add a new field to all docs

I need to add a new field to each document in a Solr index.

This new field does not need to be searchable. It is just needed to be stored in Solr and returned in the search results.

The value of the new field can be calculated based on the id field (and other info which is not present in the solr index.)

What is the fastest, most simple way to achieve this goal?

Upvotes: 0

Views: 561

Answers (1)

marius_neo
marius_neo

Reputation: 1595

Try the Solr Schema API:

curl http://localhost:8983/solr/yourcollection/schema -X POST -H 'Content-type:application/json' --data-binary '{
    "add-field" : {
    "name":"myfield",
    "type":"string",
    "stored":true
    }
}'

Filling the value of this field for the existing documents can be done AFAIK only with a reindex operation.

Upvotes: 1

Related Questions