Lucene 3: Lucene index file format (2)

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.