Github user maedhroz commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/47#discussion_r69510618
  
    --- Diff: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java 
---
    @@ -766,16 +766,29 @@ public Document doc(int i, Set<String> fields) throws 
IOException {
         }
     
         final DirectoryReader reader = getIndexReader();
    -    if (!enableLazyFieldLoading || fields == null) {
    -      d = reader.document(i);
    +    boolean containsAllFields = true;
    +    
    +    if (fields != null) {
    +      if (enableLazyFieldLoading) {
    +        final SetNonLazyFieldSelector visitor = new 
SetNonLazyFieldSelector(fields, reader, i);
    +        reader.document(i, visitor);
    +        d = visitor.doc;
    +      } else {
    +        d = reader.document(i, fields);
    +        containsAllFields = false;
    +      }
         } else {
    -      final SetNonLazyFieldSelector visitor = new 
SetNonLazyFieldSelector(fields, reader, i);
    -      reader.document(i, visitor);
    -      d = visitor.doc;
    +      d = reader.document(i);
         }
     
         if (documentCache != null) {
    -      documentCache.put(i, d);
    +      // Only cache the already retrieved document if it is complete... 
    +      if (containsAllFields) {
    +        documentCache.put(i, d);
    +      } else {
    +        // ...and retrieve a complete document for caching otherwise.
    +        documentCache.put(i, reader.document(i));
    +      }
    --- End diff --
    
    @shalinmangar I've made a pass at restoring the previous caching behavior 
(with some comments around the rationale). It feels like we might have a 
complete solution at this point.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to