Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The FieldCache uses weak references to index readers as keys for their cache. (By calling <code>IndexReader.GetCacheKey</code> which has been un-obsoleted.) A standard call to <code>IndexReader.Open</code> with a <code>FSDirectory</code> will use a pool of readers, one for every segment.</p> <p>You should always pass the innermost reader to the FieldCache. Check out <code>ReaderUtil</code> for some helper stuff to retrieve the individual reader a document is contained within. Document ids wont change within a segment, what they mean when describing it as unpredictable/volatile is that it will change between two index commits. Deleted documents could have been proned, segments have been merged, and such actions.</p> <p>A commit needs to remove the segment from disk (merged/optimized away), which means that new readers wont have the pooled segment reader, and the garbage collection will remove it as soon as all older readers are closed.</p> <p>Never, ever, call <code>FieldCache.PurgeAllCaches()</code>. It's meant for testing, not production use.</p> <p>Added 2011-04-03; example code using subreaders.</p> <pre><code>var directory = FSDirectory.Open(new DirectoryInfo("index")); var reader = IndexReader.Open(directory, readOnly: true); var documentId = 1337; // Grab all subreaders. var subReaders = new List&lt;IndexReader&gt;(); ReaderUtil.GatherSubReaders(subReaders, reader); // Loop through all subreaders. While subReaderId is higher than the // maximum document id in the subreader, go to next. var subReaderId = documentId; var subReader = subReaders.First(sub =&gt; { if (sub.MaxDoc() &lt; subReaderId) { subReaderId -= sub.MaxDoc(); return false; } return true; }); var values = FieldCache_Fields.DEFAULT.GetInts(subReader, "newsdate"); var value = values[subReaderId]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload