On Fri, Jan 1, 2010 at 9:13 PM, evana <evre...@ymail.com> wrote: > > Hi, > > I am trying to import a csv file (without "id" field) on solr 1.4 > In schema.xml "id" field is set with required="false". > But I am getting "org.apache.solr.common.SolrException: Document missing > required field: id" > > Following is the schema.xml fields section > <fields> > <field name="id" type="string" indexed="true" stored="true" > required="false" /> > <field name="name" type="textgen" indexed="true" stored="true"/> > <field name="text" type="text" indexed="true" stored="true" > multiValued="true"/> > > <dynamicField name="ignored_*" type="ignored" multiValued="true"/> > <dynamicField name="random_*" type="random" /> > <dynamicField name="*" type="string" indexed="true"/> > </fields> > > <uniqueKey>id</uniqueKey> > > > Following is the csv file > company_id,customer_name,active > 58,Apache,Y > 58,Solr,Y > 58,Lucene,Y > 60,IBM,Y > > Following is the solrj import client > SolrServer server = new > CommonsHttpSolrServer("http://localhost:8080/solr"); > ContentStreamUpdateRequest req = new > ContentStreamUpdateRequest("/update/csv"); > req.addFile(new File(filename)); > req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); > NamedList result = server.request(req); > System.out.println("Result: " + result); > > > Could any of you help out please. > > Thanks > -- > View this message in context: > http://old.nabble.com/solr-1.4-csv-import-----Document-missing-required-field%3A-id-tp26990048p26990048.html > Sent from the Solr - User mailing list archive at Nabble.com. > > The presence of the uniqueKey definition implicitly implies that the id field is a required field in the document even tough the attribute is set to false on the field definition.
Try removing the uniqueKey definition for the id field in the schema.xml file and then try again to run the update script or application. The uniqueKey definition is not needed if you are going to build the index from scratch each time you do the import. However, if you are doing incremental updates, this field is required and the uniqueKey definition is also needed too to specify what the "primary key" for the doucment is. http://wiki.apache.org/solr/UniqueKey -- "Good Enough" is not good enough. To give anything less than your best is to sacrifice the gift. Quality First. Measure Twice. Cut Once. http://www.israelekpo.com/