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 Sepehr <se...@gmail.com> on 2010/04/20 20:43:09 UTC

Solrj - Document [null] missing required field: id

Hi All,

I have a problem when indexing documents with Solrj. I have a Java
bean and when I try to index my object using addBean method, I get a
bad request response from Solr, complaining with this message:
"SEVERE: org.apache.solr.common.SolrException: Document [null] missing
required field: id". But I am specifically setting the id field on my
bean. I read somewhere that this might be because of unique key
constraint, but I have tried very unique ids too.

I have this in my schema: <field name="id" type="string"
indexed="true" stored="true" required="true" />
I have a @Field String id; in my Java class and I use the setId(String
id) method after constructing my object. My object is correctly
constructed and is not null either.
I don't understand what is going wrong here.

Thanks,
Sepehr

Re: Solrj - Document [null] missing required field: id

Posted by Tan-Vinh Nguyen <ci...@googlemail.com>.
Sepehr wrote:
> Hi All,
> 
> I have a problem when indexing documents with Solrj. I have a Java
> bean and when I try to index my object using addBean method, I get a
> bad request response from Solr, complaining with this message:
> "SEVERE: org.apache.solr.common.SolrException: Document [null] missing
> required field: id". But I am specifically setting the id field on my
> bean. I read somewhere that this might be because of unique key
> constraint, but I have tried very unique ids too.
> 
> I have this in my schema: <field name="id" type="string"
> indexed="true" stored="true" required="true" />
> I have a @Field String id; in my Java class and I use the setId(String
> id) method after constructing my object. My object is correctly
> constructed and is not null either.
> I don't understand what is going wrong here.
> 
> Thanks,
> Sepehr

Do you have this entry

<uniqueKey>id</uniqueKey>

in your schema.xml?

Another reason might be that JPA uses uppercase identifiers. Annotate
your field explicitly like that

@Id
@Column(name="id")
private String id;

Kind regards

tn