0

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?

Anton Soradoi
  • 1,841
  • 1
  • 22
  • 36
  • 1
    Why do you have to have this as TrieIntField? Can you not use ? They are all sub classes of non tokekenized field. – Arun Dec 24 '13 at 16:50
  • @Arun good point, I would have to test to see if there are any differences in performance though. – Anton Soradoi Dec 24 '13 at 17:35
  • Hi Anton, I had see 25 million docs indexed with id as string. no issues. But if you see some performance, let me know. – Arun Dec 24 '13 at 18:24
  • @Arun Thanks for your input! I will still run some tests as I have multiple fields like this and only used id here for example purposes. I'll post back how that works out. Would you mind posting your first comment as a reply so that people can vote it up? – Anton Soradoi Dec 24 '13 at 18:48
  • Testing for your own data is always good. I posted it answer. – Arun Dec 24 '13 at 18:51

2 Answers2

1

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.

Arun
  • 1,777
  • 10
  • 11
0

Solr is written in Java so it is expected. You have to either filter out non-integer value from your client side (or API layer) or use String type as Arun suggested.

kee
  • 10,969
  • 24
  • 107
  • 168
  • Thanks or your reply! Well, I wasn't expecting it... I'm looking for a way to manage this on configuration level without going into code. – Anton Soradoi Dec 24 '13 at 17:39