Skip to content

Commit

Permalink
Fixed sort by relevance with paging when sort by relevance is added a…
Browse files Browse the repository at this point in the history
…longside other sort fields.
  • Loading branch information
payammeyer committed Nov 26, 2019
1 parent a6f2a60 commit 0ecc89d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,16 @@ private void handleSortValues(ZuliaQuery.SortRequest sortRequest, ScoreDoc score
for (Object o : result.fields) {
if (o == null) {
sortValues.addSortValue(ZuliaQuery.SortValue.newBuilder().setExists(false));
c++;
continue;
}

ZuliaQuery.FieldSort fieldSort = sortRequest.getFieldSort(c);
String sortField = fieldSort.getSortField();

if (ZuliaConstants.SCORE_FIELD.equals(sortField)) {
sortValues.addSortValue(ZuliaQuery.SortValue.newBuilder().setExists(false));
sortValues.addSortValue(ZuliaQuery.SortValue.newBuilder().setFloatValue(scoreDoc.score));
c++;
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ public IndexShardResponse internalQuery(Query query, final InternalQueryRequest

ZuliaQuery.SortValue sortValue = sortValues.getSortValue(sortTermsIndex);

if (sortValue.getExists()) {
if (ZuliaConstants.SCORE_FIELD.equals(sortField)) {
sortTerms[sortTermsIndex] = sortValue.getFloatValue();
}
else if (sortValue.getExists()) {
if (FieldTypeUtil.isNumericOrDateFieldType(sortType)) {
if (FieldTypeUtil.isNumericIntFieldType(sortType)) {
sortTerms[sortTermsIndex] = sortValue.getIntegerValue();
Expand Down

0 comments on commit 0ecc89d

Please sign in to comment.