Providing a replacement for missing values in the sort DSL currently has two limitations: 1. One can only use it with numeric values, because org.apache.lucene.search.SortField.setMissingValue(Object) does not accept replacements for String values, and a SortField is what we return ultimately. 2. Field bridges are ignored, because:
- Field bridges cannot convert an object to a numeric value (the most they can do is provide a String value by implementing StringBridge), but {org.apache.lucene.search.SortField.setMissingValue(Object) excepts numeric values for numeric fields, and a SortField is what we return ultimately. Note that setMissingValue won't break right away, but org.apache.lucene.search.SortField.getComparator(int, int) (called before sorting) will.
- String values are irrelevant (see 1. above)
These limitations should go away when dropping the reliance on the Lucene API in HS 6.0. Allowing to use field bridges on numeric fields might require some more work, though. |