Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr Error Document is missing mandatory uniqueKey field id

Tags:

solr

While Importing the data into Solr using DataImportHandler, I am getting the below error. Please someone provide your suggestion.

org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: id
        at org.apache.solr.update.AddUpdateCommand.getIndexedId(AddUpdateCommand.java:92)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:717)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:557)
        at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)
        at org.apache.solr.handler.dataimport.SolrWriter.upload(SolrWriter.java:70)
        at org.apache.solr.handler.dataimport.DataImportHandler$1.upload(DataImportHandler.java:235)
        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:512)
        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:416)
        at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:331)
        at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:239)
        at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:411)
        at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:483)
        at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:464)
like image 793
Mukesh G Avatar asked Jan 08 '23 22:01

Mukesh G


2 Answers

In the schema.xml file you have mentioned id as required field = true.

Also the document that you are trying to index in SOLR do not contain this id field and hence SOLR is throwing this error.

Solution

  1. Either add id to all your documents

OR

  1. Remove required = true form schema file for id field.

Please share your schema.xml file and the documents that you are trying to index into SOLR.

Also keep in mind if you want quick response try to provide as much details as you can.

like image 114
Jayesh Bhoyar Avatar answered Mar 08 '23 06:03

Jayesh Bhoyar


this is probably where the error reporting should be improved for solr

for my case, I've defined a string field not related with KEY, and I am trying to put a null value to that field. I should probably indicate the field is nullable.

like image 37
zinking Avatar answered Mar 08 '23 06:03

zinking