I was surprised that you could sort by this field since it is stored as a long. In general, Lucene is based on strings. I always store fields that I want to query on as strings. You can use this class:
Yes, I agree this is wrong (although it is okay for the photos project for now). Sorting documents in memory isn't good, Lucene has to do that for us. You can propose something, but this should be easy and intuitive.
The query parser doesn't support numeric fields, but I think I can modify it to do this. I would identify any value starting with "#" as a number. If the number ends with "L", it would be long. If it contains a "." then it is double. Else it is integer. Then your query would be: