reindexing json object into solr by adding only un

2019-09-10 06:19发布

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

标签: solr solrj
1条回答
聊天终结者
2楼-- · 2019-09-10 07:20

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 :)

查看更多
登录 后发表回答