Someone able to make an example of something being stored in the database as something quite precise (like java.time.Instant) but then want it indexed in a more coarse precision?
Sanne Grinovero Yes, it happens. For instance I have an Instant on my business object representing the date/time it was created, but I want to query by day of creation (so, a LocalDate or OffsetDate). Typically the second-precision is only useful when displaying the data (well, not "useful", but let's say "nice"), not when searching: end users generally don't have a specific millisecond in mind when searching. I guess we could also instruct application developpers to use range queries in that case. It would have been quite hard to do with the old-time java time library (because you have to find the instant at the beginning of the day and the instant at the end of the day, which requires some boilerplate code), but it's probably a one-liner with java.time. |