On 5/9/2013 7:44 PM, zaheer.java wrote: > I repeatedly get this error while adding documents to SOLR using SOLRJ > "Document is missing mandatory uniqueKey field: orderItemKey". This field > is defined as uniqueKey in the Document Schema. I've made sure that I'm > passing this field from Java by logging it upfront. > > As suggested somwhere, I've tried upgrading from 4.0 to 4.3, and also made > the field as "required=false".
If you have a uniqueKey defined in your schema, then every document must define that field or you'll get the error message you're seeing. That's the entire point of a uniqueKey. It is pretty much the same concept as a primary key on a database table. There is one main difference between uniqueKey and a DB primary key - the database will prevent you from inserting a record with the same ID as an existing record, but Solr uses it to allow easy reindexing. Sending a document with the same ID as an existing document will cause Solr to delete the old one before inserting the new one. Certain Solr features, notably distributed search, require a uniqueKey. SolrCloud uses distributed search so it also requires it. If you're not using features that require uniqueKey, and you don't need Solr to delete duplicate documents, then you can remove that from your schema. It's not recommended, but it should work. Thanks, Shawn