Prashant Patil
Prashant Patil

Reputation: 2563

How to add a extra field to Solr while importing CSV file?

I'm Importing data in solr from the shell script

./bin/post -c <core name> $DOWNLOADFILE

There are some fields in CSV file like Name, Email, Phone,Added_on,Updated_on

Now I want to add another field is_deleted = 0 into solr in every record after successful import.

so how to do that?

Upvotes: 2

Views: 112

Answers (2)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

Add a field in schema.xml like below.

<field name="is_deleted" type="int" indexed="true" stored="true" default="0" />

If the data is not provided while indexing, then solr will use the default value specified in the schema.xml file. If default is not defined, solr ignores this field. If field is marked as required in schema.xml - solr will reject this document with error.

Upvotes: 1

aswath86
aswath86

Reputation: 571

In your schema you can add this,

  <field name="is_deleted" type="pint" default="0" indexed="true" stored="true"/>

If the field is empty the default value will be indexed.

Upvotes: 1

Related Questions