[
https://issues.apache.org/jira/browse/SOLR-11132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16161732#comment-16161732
]
ASF subversion and git services commented on SOLR-11132:
--------------------------------------------------------
Commit 69c8bbcb51481d9759eef10490b87d89de90e98d in lucene-solr's branch
refs/heads/branch_7x from Chris Hostetter
[ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=69c8bbc ]
SOLR-11332, SOLR-11132: Fix sorting on 'enum' fieldTypes that use
sortMissingFirst or sortMissingLast and Refactor common getSortField logic in
various FieldTypes
(cherry picked from commit 31eab319f4b2632f1be488be3c1008b3567c6142)
> Refactor common getSortField logic in various FieldTypes
> --------------------------------------------------------
>
> Key: SOLR-11132
> URL: https://issues.apache.org/jira/browse/SOLR-11132
> Project: Solr
> Issue Type: Improvement
> Security Level: Public(Default Security Level. Issues are Public)
> Reporter: Hoss Man
> Assignee: Hoss Man
> Attachments: SOLR-11132.patch, SOLR-11132.patch
>
>
> This pattern exists a lot w/ some minor fluxuations in copy/paste variation...
> {code}
> @Override
> public SortField getSortField(SchemaField field, boolean top) {
> field.checkSortability();
> Object missingValue = null;
> boolean sortMissingLast = field.sortMissingLast();
> boolean sortMissingFirst = field.sortMissingFirst();
> if (sortMissingLast) {
> missingValue = top ? SOMECLASS.MIN_VALUE : SOMECLASS.MAX_VALUE;
> } else if (sortMissingFirst) {
> missingValue = top ? SOMECLASS.MAX_VALUE : SOMECLASS.MIN_VALUE;
> }
> SortField sf = new SortField(field.getName(), SortField.Type.SOMETYPE,
> top);
> sf.setMissingValue(missingValue);
> return sf;
> }
> {code}
> We should refactor it into a helper method along the lines of...
> {code}
> @Override
> public static SortField getSortField(SchemaField field, boolean top,
> SortField.Type sortType,
> Object missingLow, Object missingHigh)
> {
> field.checkSortability();
> Object missingValue = null;
> boolean sortMissingLast = field.sortMissingLast();
> boolean sortMissingFirst = field.sortMissingFirst();
> if (sortMissingLast) {
> missingValue = top ? missingLow : missingHigh;
> } else if (sortMissingFirst) {
> missingValue = top ? missingHigh : missingLow;
> }
> SortField sf = new SortField(field.getName(), sortType, top);
> sf.setMissingValue(missingValue);
> return sf;
> }
> {code}
> So it can be re-used via...
> {code}
> @Override
> public SortField getSortField(SchemaField field, boolean top) {
> return getSortField(field, top, SortField.Type.SOMETIME,
> SOMECLASS.MIN_VALUE, SOMECLASS.MAX_VALUE);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]