问题
Anyone have an example of how to use IndexWriter.SetMergedSegmentWarmer in Lucene.Net?
When I try something like...
IndexWriter.IndexReaderWarmer warmer = new IndexWriter.IndexReaderWarmer();
indexWriter.SetMergedSegmentWarmer(warmer);
I get
Cannot create an instance of the abstract class or interface 'Lucene.Net.Index.IndexWriter.IndexReaderWarmer'
回答1:
Well, you should write your own. IndexWriter.IndexReaderWarmer
is abstract class, so it doesn't provide warm up implementation. The purpose of this class is to define contract between IndexReader
and IndexReaderWarmer
so they can communicate appropriately.
Writing your own implementation is not easy task. You should decide how exactly you will warm the reader up. Several ideas:
- perform recently executed queries over new reader;
- perform static bunch of queries;
- perform
FieldCache
preload only.
来源:https://stackoverflow.com/questions/12271614/lucene-net-indexwriter-setmergedsegmentwarmer