The ValuesSources provide a getSortField method that always supplies 0 as the "missing value" - ie the default value for documents that do not advance the source.
But if an application wants to provide "missing last" or "missing first" semantics, it needs to control the missing value depending on the possible range of values and whether the sort is ascending or descending. Yet if you call setMissingValue() on one of these SortFields, you get an Exception: throw new IllegalArgumentException("Missing value only works for numeric or STRING types"); But these *are* numeric types, or they seem that way. Internally they are labeled as type CUSTOM. First, my question is whether there is a way to achieve the desired behavior -- missing last semantics combined with sorting on ValuesSource? And if there isn't a good way, would it make sense to default to "missing last", providing a default value of MIN or MAX depending on whether the sort is descending or ascending, or maybe just allow setMissingValue to be called for these fields?