On 6/8/06, Darren Vengroff <[EMAIL PROTECTED]> wrote:
I just ran across a situation where, in building my schema.xml file, I
forgot to specify the <field /> for the field that I was using as my
<uniqueKey />.  It was totally my error, but having no idea what the error
was, I had to spend some time debugging.  Once I realized what was going on,
I made a little change to IndexSchema.java to ensure that something appears
in the log in this situation.  The previous behavior was to simply throw a
RuntimeException, which, in Tomcat at least, did not result in anything easy
to spot in any of the logs I checked.

Hmmm, I just tried removing my "id" field in Tomcat, and I did get an
exception chain ending with
Caused by: java.lang.RuntimeException: unknown field 'id'

If the schema defines a uniqueKeyField, and that field doesn't exist,
shouldn't we throw an exception rather than just logging it?  It seems
like a rather fatal error.

Note also that the code that looks for a <defaultSearchField /> already
assumed that getIndexedField(String) could return a null, although that code
path was unreachable given the throw that this patch removed.

Must have been a late night :-)  I assume I meant
     defaultSearchFieldName = defName!=null ? getIndexedField(defName) : null;
rather than
     defaultSearchFieldName = getIndexedField(defName)!=null ? defName : null;


-Yonik

Reply via email to