On 8/8/07, Ryan McKinley <[EMAIL PROTECTED]> wrote: > In the trunk code, the DocumentBuilder is not handling null values well. > > SolrInputDocument doc = new SolrInputDocument(); > doc.addField( "id", "hello", 1.0f ); > doc.addField( "name", null, 1.0f ); > > Document out = DocumentBuilder.toDocument( doc, core.getSchema() ); > > throws an exception: > > "unknown field 'name'" > > Fixing it is easy, but I'm not clear what the semantics of indexing a > 'null' value is indented to be.
Don't index it. > It looks like FieldTypes are given a > chance to deal with 'null' values with the toInternal() > > I have not looked into it, but I think the StAX parser would make both: > <field name="name" /> > <field name="name" ></field> > into: doc.addField( "name", "", 1.0f ); That's partially an XML issue. There is no way to distinguish between those two cases, and the latter is the most reasonable way to represent a zero length string... hence "null" is not expressible in the XML. But we do have a way to express that a field has no value: just leave it out. > To me, it makes the most sense to just skip fields that don't have any > value. A zero length string is a legal value for a string. -Yonik