mraible commented on code in PR #226:
URL: https://github.com/apache/roller/pull/226#discussion_r4402290037
##########
app/src/main/java/org/apache/roller/weblogger/business/search/lucene/LuceneIndexManager.java:
##########
@@ -432,44 +432,50 @@ static SearchResultList convertHitsToEntryList(
List<WeblogEntryWrapper> results = new ArrayList<>();
- // determine offset
- int offset = pageNum * entryCount;
- if (offset >= hits.length) {
- offset = 0;
- }
-
- // determine limit
- int limit = entryCount;
- if (offset + limit > hits.length) {
- limit = hits.length - offset;
- }
-
try {
- Set<String> categories = new TreeSet<>();
- TreeSet<String> categorySet = new TreeSet<>();
Weblogger roller = WebloggerFactory.getWeblogger();
WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
- WeblogEntry entry;
- Document doc;
- String handle;
+ // The index can lag behind the entries, so page through the hits
+ // whose entry is published now (and not a future post). Only
+ // those count toward the offset and limit.
+ List<WeblogEntry> visible = new ArrayList<>();
+ List<Document> visibleDocs = new ArrayList<>();
Timestamp now = new Timestamp(new Date().getTime());
- for (int i = offset; i < offset + limit; i++) {
- doc = search.getSearcher().doc(hits[i].doc);
- handle =
doc.getField(FieldConstants.WEBSITE_HANDLE).stringValue();
- entry =
weblogMgr.getWeblogEntry(doc.getField(FieldConstants.ID).stringValue());
+ for (ScoreDoc hit : hits) {
Review Comment:
This loop now loads the stored document and the `WeblogEntry` for every hit,
up to SearchOperation's 500-doc limit. Before, it only loaded the requested
page (10 by default), so a public search can go from about 10 entity loads to
500. Could the loop stop once it has `offset + limit` visible entries? Drafts
still wouldn't use up a page slot.
--
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]