Search code examples
solrconfigurationlucenesolr-schema

why in solr 1.4 passing a letter to a 'int' field results in exception?


I'm running lucene solr 1.4 on top of tomcat.

I have a field id defined with type int which is mapped to solr.TrieIntField.

When I do a solr query like ?q=id:a I get a NumberFormatException.

Is it possible to configure solr in such a way that it returns empty result set for above scenraio instead of throwing the exception?


Solution

  • Why do you have to have this as TrieIntField? Can you not use ? They are all sub classes of non tokekenized field (org.apache.solr.schema.FieldType).

    Update: Based on your original question, as it is about id, i suggested to use string, as it makes no difference in that case. But if other fields use TrieIntField type the downside of using string for those fields is that your sorts and range queries may go string based and may be not desirable. In that case you need to prevent your orignal problem in client API or you need to handle them better by writing your own handler. Solr is doing correct thing by giving error as most applications would capure this error and respond to users with better user error message. If solr returns no results instead of error then it would be missleading.