thomasmueller commented on code in PR #3124:
URL: https://github.com/apache/jackrabbit-oak/pull/3124#discussion_r4027254596
##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java:
##########
@@ -268,6 +289,9 @@ public Cursor query(final IndexPlan plan, NodeState
rootState) {
}
final Filter filter = plan.getFilter();
final Sort sort = getSort(plan);
+ // OAK-12399: when the sort includes the relevance score, scores must
be tracked explicitly,
+ // otherwise Lucene returns NaN for a field sort.
+ final boolean needsScores = requiresScores(sort);
Review Comment:
We need to check the feature toggle, either here or in the requiresScores
method.
##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java:
##########
@@ -373,14 +397,16 @@ private boolean loadDocs() {
if (sort == null) {
docs = searcher.searchAfter(lastDoc,
query, nextBatchSize);
} else {
- docs = searcher.searchAfter(lastDoc,
query, nextBatchSize, sort);
+ // OAK-12399: needsScores as doDocScores
so a jcr:score sort field is populated.
+ docs = searcher.searchAfter(lastDoc,
query, null, nextBatchSize, sort, needsScores, false);
}
} else {
LOG.debug("loading the first {} entries for
query {}", nextBatchSize, query);
if (sort == null) {
docs = searcher.search(query,
nextBatchSize);
} else {
- docs = searcher.search(query,
nextBatchSize, sort);
+ // OAK-12399: needsScores as doDocScores
so a jcr:score sort field is populated.
+ docs = searcher.search(query, null,
nextBatchSize, sort, needsScores, false);
Review Comment:
Same as above
##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java:
##########
@@ -373,14 +397,16 @@ private boolean loadDocs() {
if (sort == null) {
docs = searcher.searchAfter(lastDoc,
query, nextBatchSize);
} else {
- docs = searcher.searchAfter(lastDoc,
query, nextBatchSize, sort);
+ // OAK-12399: needsScores as doDocScores
so a jcr:score sort field is populated.
+ docs = searcher.searchAfter(lastDoc,
query, null, nextBatchSize, sort, needsScores, false);
Review Comment:
If the feature toggle is disabled, then the old code needs to be called. We
could have an "if" condition here for the feature toggle, or maybe it's enough
to have one for the needsScores
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]