sachin kumar
sachin kumar

Reputation: 19

reindexing json object into solr by adding only unique elements

I have indexed json object into solr using httpclient and when I tried to index again, duplicate records are getting indexed.

So how to update the records into solr, everytime I index I want to update the records.

Thanks in advance

Upvotes: 0

Views: 184

Answers (1)

Saurabh Chaturvedi
Saurabh Chaturvedi

Reputation: 2156

In your JSON Object include an ID field inside your json object and it should be unique, for example some random number like 65746 . When you will try to index this document again, solr will check for id .If id is same, solr will not index that whole document again . Now the question is how you declare a unique field in solr schema . So for that go to your schema.xml file or managed-schema file which is inside your core configuration and define unique field like this id . Now solr will identify id coming from your JSON as unique , and won't indexed already indexed documents.Hence there will be no duplicate records. Let me know if that helped you :)

Upvotes: 1

Related Questions