Hi.

I'm confused by the UUID type comment. It's said that

 /**
   * Generates a UUID if val is either null, empty or "NEW".
   *
   * Otherwise it behaves much like a StrField but checks that the value
given
   * is indeed a valid UUID.
   *
   * @param val The value of the field
   * @see org.apache.solr.schema.FieldType#toInternal(java.lang.String)
   */

However, i found that if i don't specify the field and it will report the
exception

org.apache.solr.common.SolrException: Document [test] missing required
field: id

Surely when i set it to "NEW", it will work as expected.

I want to know that is this a expected way or should be possible a bug?

The related codes should be:

   for (SchemaField field : schema.getRequiredFields()) {
      if (out.getField(field.getName() ) == null) {
*        if (field.getDefaultValue() != null) {            //  Here because
the default value is null.  I think we should judge whether it's a UUID
field.
          out.add( field.createField( field.getDefaultValue(), 1.0f ) );
        } *
        else {
          String id = schema.printableUniqueKey( out );
          String msg = "Document ["+id+"] missing required field: " +
field.getName();
          throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, msg
);
        }
      }
    }

Thanks for help.

Best regards.

sishen

Reply via email to