Whats the fastest way to loading all of the values of 开发者_如何学Ca lucene index field in memory,
Whats the fastest way to loading all of the values of
开发者_如何学Ca lucene index field in memory,
I have large lucene index (1.6 GB) i need to load all of the (ID) field into memory with least overhead on memory I'm getting OutOfMemoryException when i iterate through all of the items and read that field (this is also very slow for loading field of index i need a solution with better performance).
You may need to address why you need to load of your Fields into memory in the first place?
Have you tried doing a search using a TermQuery and a Term that simply contains the field you want to load? e.g. new Term("ID").
You then wont need to load all values into memory to iterate over them. Instead, use a FieldSelector to ensure only a single field is loaded when you load each search result.
Otherwise, use Lucene's FieldCache to get the values for all your ID fields.
精彩评论