You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Israel Ekpo <is...@gmail.com> on 2010/01/02 06:27:51 UTC

Re: solr 1.4 csv import -- Document missing required field: id

On Fri, Jan 1, 2010 at 9:13 PM, evana <ev...@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/

Re: solr 1.4 csv import -- Document missing required field: id

Posted by Lance Norskog <go...@gmail.com>.
You seem to have 'company' as your unique key. You can change the
schema.xml to use 'company' as the uniqueId. There is nothing magic
about the field name 'id'.

While it is possible to have a Solr schema without a unique key,
almost nobody does this. A unique key makes working with Solr much
simpler.

On Sat, Jan 2, 2010 at 7:53 AM, Yonik Seeley <yo...@lucidimagination.com> wrote:
> On Sat, Jan 2, 2010 at 12:27 AM, Israel Ekpo <is...@gmail.com> wrote:
>> 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.
>
> Further, if you know you aren't adding any duplicate documents, you
> can temporarily disable document overwriting by adding
> "overwrite=false" to the request.
>
> -Yonik
> http://www.lucidimagination.com
>



-- 
Lance Norskog
goksron@gmail.com

Re: solr 1.4 csv import -- Document missing required field: id

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Sat, Jan 2, 2010 at 12:27 AM, Israel Ekpo <is...@gmail.com> wrote:
> 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.

Further, if you know you aren't adding any duplicate documents, you
can temporarily disable document overwriting by adding
"overwrite=false" to the request.

-Yonik
http://www.lucidimagination.com

Re: solr 1.4 csv import -- Document missing required field: id

Posted by evana <ev...@ymail.com>.
Thanks for quick reply.

As per you suggestion I commented uniqueKey element in schema.xml and
QueryElevationComponent in solrconfig.xml. 
After that its working like charm.
I appreciate your help.

--evana



Israel Ekpo wrote:
> 
> On Fri, Jan 1, 2010 at 9:13 PM, evana <ev...@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/
> 
> 

-- 
View this message in context: http://old.nabble.com/solr-1.4-csv-import-----Document-missing-required-field%3A-id-tp26990048p26991722.html
Sent from the Solr - User mailing list archive at Nabble.com.