I was wondering why my sortMissingLast=true directives started being ignored for some of my fields. It turns out it is because I switched them from solr.StrField to solr.TextField in order to have them analyzed (using KeywordTokenizer with PatternReplaceFilter to do strip whitespace and punctuation); StrField defines getSortField as

        return getStringSort(field,reverse);

while TextField defines it as

        return new SortField(field.name,SortField.STRING, reverse);

The difference being that getStringSort returns a SortField which respects sortMissingXXX by using a custom SortComparatorSource when needed.

In my case a simple workaround is to go back to StrField but set tokenized=true, making it effectively identical to TextField other than sorting.

But noting that BCDIntField and its subclasses, BoolField, and all the SortableXXField(s) call getStringSort rather than directly creating a STRING SortField, I wonder whether TextField's not doing so is a feature or a bug?

- J.J.

Reply via email to