Created
August 14, 2012 19:50
-
-
Save zgramana/3352238 to your computer and use it in GitHub Desktop.
Eager loading Lucene.Net docs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only load the fields that the query asks for. | |
// The Lucene.Net signature for this is wonky, as | |
// Java Lucene takes a Set<String>. As a result, | |
// we are obliged to create this hashtable where | |
// the keys == values. | |
var loadFields = new Hashtable(); | |
foreach (var fieldName in request.ResultFields) | |
{ | |
loadFields.Add(fieldName, fieldName); | |
} | |
// No lazy loading, since we already know exactly | |
// which fields we need to work with. | |
var selector = new SetBasedFieldSelector(loadFields, new Hashtable()); | |
var luceneDoc = reader.Document(aDoc, selector); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment