diff --git a/zulia-server/src/main/java/io/zulia/server/index/ShardReader.java b/zulia-server/src/main/java/io/zulia/server/index/ShardReader.java index 817514e9..a7047395 100644 --- a/zulia-server/src/main/java/io/zulia/server/index/ShardReader.java +++ b/zulia-server/src/main/java/io/zulia/server/index/ShardReader.java @@ -574,6 +574,7 @@ 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; } @@ -581,7 +582,8 @@ private void handleSortValues(ZuliaQuery.SortRequest sortRequest, ScoreDoc score 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; } diff --git a/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java b/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java index 0cb7df8f..91f857cb 100644 --- a/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java +++ b/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java @@ -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();