OK, put it back <G>.... According to this page: http://wiki.apache.org/solr/DataImportHandler#Configuration_in_data-config.xml-1 the pk is used for delta imports and "has no relation to uniqueKey defined in the schema.xml...".
The error you're getting is because your schema.xml defines the "id" field as required (required="true"), assuming you're just using the example schema and/or your <uniqueKey> field is "id". You have two choices: 1> form your select such that every document gets an id. That is the <field column="fileNo" name="id"> will do if (and only if) you select fileNo in your select statement. Just ignore the pk for this puprose 2> remove the "required='true'" form your id field definition in schema.xml. AND remove the <uniqueKey>id</uniqueKey> entry. The second will make it hard to do delta imports, so I'd go for the first. The point is that whatever field you use to populate the <id> key should uniquely identify the record so it may be updated. Hope that helps Erick On Tue, May 3, 2011 at 12:54 PM, serenity keningston <serenity.kenings...@gmail.com> wrote: > Dear Erick, > > I am using Solr 1.4 version. Yes, for each row , we will get one fileNo > which is the primary key for the table "file". > No, I intentionally removed the <field column="fileNo" name="id"> from the > data-config.xml > > I tried opening the dataimport.jsp to debug but I don't know, it doesn't > show any result but it updates the log file every time I tried to debug. > > Regards, > Serenity > > On Tue, May 3, 2011 at 11:42 AM, Erick Erickson > <erickerick...@gmail.com>wrote: > >> The next thing to check is if your select statement returns the >> fileNo for every field. >> >> Wait.. You took out the <field column="fileNo" name="id"> bit of your >> entity >> definition, is that a cut/paste error? >> >> You might get some joy from the DIH debug page at: >> <solr home>solr/admin/dataimport.jsp >> it's not very well known, but it's a debug console for >> your SQL data import process. >> >> >> BTW, what version of Solr are you using? >> >> Best >> Erick >> >> On Tue, May 3, 2011 at 12:04 PM, serenity keningston >> <serenity.kenings...@gmail.com> wrote: >> > Dear Stefan, >> > >> > Am still getting the following error message even after including the >> > pk-Attribute to the query : >> > >> > WARNING: Error creating document : >> > SolrInputDocument[{lname=lname(1.0)={cindy}, file=file(1.0)={ >> > http://localhost:8084/Access/UploadFiles/laura.mp3}, >> > fname=fname(1.0)={troutman}}] >> > org.apache.solr.common.SolrException: Document [null] missing required >> > field: id >> > at >> > >> org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:305) >> > at >> > >> org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:60) >> > at >> > org.apache.solr.handler.dataimport.SolrWriter.upload(SolrWriter.java:75) >> > at >> > >> org.apache.solr.handler.dataimport.DataImportHandler$1.upload(DataImportHandler.java:292) >> > at >> > >> org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:392) >> > at >> > >> org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:242) >> > at >> > >> org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:180) >> > at >> > >> org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:331) >> > at >> > >> org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:389) >> > at >> > >> org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:370) >> > >> > >> > and here is the data-config.xml file : >> > >> > <dataConfig> >> > <dataSource driver="com.mysql.jdbc.Driver" >> > url="jdbc:mysql://localhost:3306/mp3" >> > user="root" >> > password="root" /> >> > <document> >> > <entity name="file" pk="fileNo" query="select fname, lname, file, >> fileNo >> > from mp3.file"> >> > >> > <field column="fname" name="fname" /> >> > <field column="lname" name="lname" /> >> > <field column="file" name="file" /> >> > </entity> >> > </document> >> > </dataConfig> >> > >> > Regards, >> > Serenity >> > >> > On Tue, May 3, 2011 at 10:43 AM, Stefan Matheis < >> > matheis.ste...@googlemail.com> wrote: >> > >> >> Serenity, >> >> >> >> there is no field fileNo in your SELECT-Query? you've defined it in >> >> the pk-Attribut of the <entity> Tag, but it's also required in the >> >> Query itself. just to note it: you can skip your <field> definition, >> >> if the query returns the field with exactly the same name as the >> >> solr-schema requires it. >> >> >> >> Regards >> >> Stefan >> >> >> >> On Tue, May 3, 2011 at 5:38 PM, serenity keningston >> >> <serenity.kenings...@gmail.com> wrote: >> >> > Hello Friends, >> >> > >> >> > >> >> > I am new to Solr and experiencing issue while trying to use >> >> > DataImportHandler. I added the required fields to schema.xml file and >> >> here >> >> > is my data-config.xml file : >> >> > >> >> > <dataConfig> >> >> > <dataSource driver="com.mysql.jdbc.Driver" >> >> > url="jdbc:mysql://localhost:3306/mp3" >> >> > user="root" >> >> > password="root" /> >> >> > <document> >> >> > <entity name="file" pk="fileNo" query="select fname, lname, file >> from >> >> > mp3.file"> >> >> > <field column="fileNo" name="id"/> >> >> > <field column="fname" name="fname" /> >> >> > <field column="lname" name="lname" /> >> >> > <field column="file" name="file" /> >> >> > </entity> >> >> > </document> >> >> > </dataConfig> >> >> > >> >> > I am getting the following errors : >> >> > >> >> > org.apache.solr.common.SolrException: Document [null] missing required >> >> > field: id >> >> > >> >> > solr home defaulted to 'solr/' (could not find system property or >> JNDI) >> >> > May 3, 2011 9:59:08 AM org.apache.solr.core.SolrResourceLoader <init> >> >> > INFO: Solr home set to 'solr/' >> >> > >> >> > DataImportHandler can extract the information from the database and it >> is >> >> > displayed in log file, however, it is not indexing the data. Can >> anyone >> >> > please let me know, where I am commiting mistake ? >> >> > >> >> > Regards, >> >> > Serenity >> >> > >> >> >> > >> >