IndexWriterwriternewIndexWriter (FSDirectory. open (INDEX_DIR), newStandardAnalyzer (Version. LUCENE_CURRENT), true, IndexWriter. maxFieldLength. LIMITED); writer. setUseCompoundFile (false); indexDocs (writer, docDir); writer. flush (); flush
IndexWriter writer = new IndexWriter (FSDirectory. open (INDEX_DIR), new StandardAnalyzer (Version. LUCENE_CURRENT), true, IndexWriter. maxFieldLength. LIMITED); writer. setUseCompoundFile (false); indexDocs (writer, docDir); writer. flush (); // flush
IndexWriter writer = new IndexWriter (FSDirectory. open (INDEX_DIR), new StandardAnalyzer (Version. LUCENE_CURRENT), true, IndexWriter. MaxFieldLength. LIMITED );
Writer. setUseCompoundFile (false );
IndexDocs (writer, docDir );
Writer. flush ();
// Flush generates the segment "_ 0", and in the flush function, flushDocStores is set to false, that is, the next segment shares the domain and word vector information with this segment, docStoreSegment = "_ 0" in DocumentsWriter ".
IndexDocs (writer, docDir );
Writer. commit ();
// Commit generates the segment "_ 1". Because the last flushDocStores was set to false, the domain and word vector information of the segment "_ 1" are saved in "_ 0, at this time point, segment "_ 1" does not generate its own "_ 1.fdx" and" _ 1.fdt ". However, in the commit function, flushDocStores is set to true, that is, the next segment uses the new segment separately to store the domain and word vector information. However, docStoreSegment = "_ 1" in DocumentsWriter, that is, when segment "_ 2" stores its domain and word vector information, it exists in "_ 1.fdx" and" _ 1.fdt, however, the domain and word Vector Information of segment "_ 1" exist in "_ 0.fdt" and" _ 0.fdx", which is very confusing. In writer. commit, _ 1. fdt and _ 1. fdx are not formed.
IndexDocs (writer, docDir );
Writer. flush ();
// Segment "_ 2" is formed. Because the last flushDocStores was set to true, the domain and word vector information are saved in _ 1. fdt and _ 1. in fdx, the two files are generated at this time.
IndexDocs (writer, docDir );
Writer. flush ();
// Segment "_ 3" is formed. Because the last flushDocStores was set to false, the domain and word vector information are shared by a segment and saved in _ 1. fdt and _ 1. in fdx
IndexDocs (writer, docDir );
Writer. commit ();
// Segment "_ 4" is formed. Because the last flushDocStores was set to false, the domain and word vector information are shared by a segment and saved in _ 1. fdt and _ 1. in fdx. However, in the commit function, flushDocStores is set to true, which means that the next segment will create a new segment to save the domain and word vector information. In this case, docStoreSegment = "_ 4 ", it also indicates that although the domain and word Vector Information of segment "_ 4" are stored in segment "_ 1, future domain and word vector information must be saved in segment "_ 4. "_ 4.fdx" and" _ 4.fdt" have not yet been generated.
IndexDocs (writer, docDir );
Writer. flush ();
// Segment "_ 5" is formed. Because the last time flushDocStores was set to true, its domain and word vector information were saved in _ 4. fdt and _ 4. in fdx, the two files are generated at this time.
IndexDocs (writer, docDir );
Writer. commit ();
Writer. close ();
// Segment "_ 6" is formed. Because the last flushDocStores was set to false, the domain and word vector information are shared by a segment and saved in _ 4. fdt and _ 4. in fdx