I learned the hard way that if you add a document with a NumericField, retrieve that document, and add it again, the copied document will end up eliding the NumericField into a regular Field, resulting in a non-prefix-coded value being indexed.
If you then attempt to sort on the field, you'll get FormatException because some fields are prefix-coded and others are human readable strings. The solution is to replace all fields on the document even if they have not changed. My question is: is this by design or is it a design flaw? I haven't seen this issue documented on NumericField.cs or anywhere else. It may not be feasible, or it may be bad for performance, but it seems like it would be more intuitive if retrieved documents retained some metadata about fields that have been encoded using NumericField. An NUnit test case that demonstrates the problem is available here: http://chriseldredge.github.com/2012/04/19/Lucene-NumericField-Gotcha.html Thanks, Chris
