Skip to content

Commit

Permalink
allow zuliaScore to be used a sort field
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavis95 committed Nov 12, 2019
1 parent 5d4fe54 commit 8cf449a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ public ZuliaQuery.ShardQueryResponse queryShard(Query query, Map<String, ZuliaBa

boolean sorting = (sortRequest != null) && !sortRequest.getFieldSortList().isEmpty();
if (sorting) {

collector = getSortingCollector(sortRequest, hasMoreAmount, after);
}
else {
Expand Down Expand Up @@ -423,7 +422,10 @@ private TopDocsCollector<?> getSortingCollector(ZuliaQuery.SortRequest sortReque
String sortField = fs.getSortField();
ZuliaIndex.FieldConfig.FieldType sortFieldType = indexConfig.getFieldTypeForSortField(sortField);

if (FieldTypeUtil.isNumericOrDateFieldType(sortFieldType)) {
if ("zuliaScore".equals(sortField)) {
sortFields.add(new SortField(null, SortField.Type.SCORE, reverse));
}
else if (FieldTypeUtil.isNumericOrDateFieldType(sortFieldType)) {

SortedNumericSelector.Type sortedNumericSelector = SortedNumericSelector.Type.MIN;
if (reverse) {
Expand Down Expand Up @@ -463,7 +465,7 @@ else if (FieldTypeUtil.isDateFieldType(sortFieldType)) {

}
Sort sort = new Sort();
sort.setSort(sortFields.toArray(new SortField[sortFields.size()]));
sort.setSort(sortFields.toArray(new SortField[0]));

collector = TopFieldCollector.create(sort, hasMoreAmount, after, Integer.MAX_VALUE);
return collector;
Expand Down

0 comments on commit 8cf449a

Please sign in to comment.