Skip to content

Commit

Permalink
Access stored fields more efficiently. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz authored Oct 19, 2023
1 parent 1d991f3 commit a9fc247
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion browse-handler/java/org/vufind/solr/handler/AuthDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Map;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.StoredFields;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
Expand Down Expand Up @@ -77,8 +78,9 @@ public List<Document> getPreferredHeadings(String heading)

List<Document> result = new ArrayList<> ();

StoredFields storedFields = searcher.getIndexReader().storedFields();
for (int i = 0; i < results.totalHits.value; i++) {
result.add(searcher.getIndexReader().storedFields().document(results.scoreDocs[i].doc));
result.add(storedFields.document(results.scoreDocs[i].doc));
}

return result;
Expand Down
3 changes: 2 additions & 1 deletion browse-indexing/PrintBrowseHeadings.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ private boolean isLinkedFromBibData(String heading)
}
}

StoredFields storedFields = authSearcher.getIndexReader().storedFields();
for (int i = 0; i < hits.scoreDocs.length; i++) {
Document doc = authSearcher.getIndexReader().storedFields().document(hits.scoreDocs[i].doc);
Document doc = storedFields.document(hits.scoreDocs[i].doc);

String[] preferred = doc.getValues(System.getProperty("field.preferred", "preferred"));
if (preferred.length > 0) {
Expand Down

0 comments on commit a9fc247

Please sign in to comment.