Lucene.Net.Linq icon indicating copy to clipboard operation
Lucene.Net.Linq copied to clipboard

Lazy field retrieval

Open chriseldredge opened this issue 11 years ago • 2 comments

Supposing a document like:

public class Book
{
  public string Title { get; set; }
  public string Author{ get; set; }
  public string Text{ get; set; }
}

And a query like:

from b in books
where b.Title == "foo" || b.Author == "bar"
select new { b.Title, b.Author };

Lucene.Net.Linq should not retrieve large, possibly compressed fields like Text since the client is not using that field.

chriseldredge avatar May 15 '13 14:05 chriseldredge

Out of curiosity, in raw Lucene, is there a performance benefit to not reading fields in a Document even though it's already been loaded from the index?

richardgavel avatar May 21 '13 14:05 richardgavel

This would be a performance optimization that may only benefit certain use cases where a given field is very large or uses compression and won't be used. See [IndexReader.Document](https://lucene.apache.org/core/old_versioned_docs/versions/3_0_1/api/all/org/apache/lucene/index/IndexReader.html#document%28int, org.apache.lucene.document.FieldSelector%29).

chriseldredge avatar May 21 '13 15:05 chriseldredge