Skip to content

Commit

Permalink
Convert TopDocAgg patch to be compliant with lucene8
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbadman authored and timatbw committed Sep 21, 2022
1 parent fcadff9 commit b8634ad
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TotalHits;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
Expand Down Expand Up @@ -295,21 +296,21 @@ private int buildResultForSlot(Query slotQuery, int slot) throws IOException {
int offset = 0;
TopDocs topDocs = fcontext.searcher.search(finalQuery, limit, sort);

long totalHits = topDocs.totalHits;
long totalHits = topDocs.totalHits.value;
int nDocsReturned = topDocs.scoreDocs.length;
float maxScore = totalHits>0 ? topDocs.getMaxScore() : 0.0f;
float maxScore = totalHits > 0 ? topDocs.scoreDocs[0].score : 0.0f;
int[] ids = new int[nDocsReturned];
float scores[] = doScores ? new float[nDocsReturned] : null;
for (int i=0; i<nDocsReturned; i++) {
ScoreDoc scoreDoc = topDocs.scoreDocs[i];
ids[i] = scoreDoc.doc;
if (scores != null) scores[i] = scoreDoc.score;
}
DocList docList = new DocSlice(offset, ids.length, ids, scores, totalHits, maxScore);
DocList docList = new DocSlice(offset, ids.length, ids, scores, totalHits, maxScore, TotalHits.Relation.EQUAL_TO);

result[slot] = new BasicResultContext(docList, returnFields , fcontext.searcher, query, fcontext.req);

return (int)topDocs.totalHits;
return (int)topDocs.totalHits.value;
}

@Override
Expand Down

0 comments on commit b8634ad

Please sign in to comment.