Skip to content

Instantly share code, notes, and snippets.

@zgramana
Created August 14, 2012 19:50
Show Gist options
  • Save zgramana/3352238 to your computer and use it in GitHub Desktop.
Save zgramana/3352238 to your computer and use it in GitHub Desktop.
Eager loading Lucene.Net docs
// 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