SOLR-related operations (adddocument, flush, commit, rollback, optimize, close)

Source: Internet
Author: User
Tags solr

SOLR usually includes the following operations, including explicit and implicit operations.

1. adddocument: analyzes and word segmentation the document and creates an index Segment segment. Each time a document is added to the flush buffer, a segment is created in the index file.

2. Commit: in addition to submitting index changes to the directory object, the searcher re-creates the query.

After the commit is submitted, the index is flushed to the hard disk, and the listener is triggered to create a new insexsearcher (New insexreader, loading the index from the hard disk ), in this way, the new insexsearcher will be used for subsequent queries.

There are two types of commit after solr4.0: Hard commit and softcommit;

During hardcommit, the document should be flushed to the storage, and a new searcher of warm will be sent. softcommit is proposed in NRT real-time search and will not be flushed to persistent storage, the document can also be searched at a much lower cost than the hardcommit. In scenarios with high real-time requirements, you can perform the softcommit operation, but you still need to schedule the hardcommit operation, make sure that the index is persistent to storage.


3. rollback: roll back the changes to the document index

4. Flush: when the size of the document index in the memory is greater than a threshold value, it will be flush to the hard disk.

If the following two conditions are met, the cache is automatically flushed to the storage. However, you cannot find the indexes that have been added but not submitted.
<Rambuffersizemb> 100 </rambuffersizemb>

<Maxbuffereddocs> 1000 </maxbuffereddocs>

After Solr4.0, The updatelog concept of transaction logs is enabled to ensure that no data is lost. After the crash, the updatelog can be used for restoration and automatic indexing, timely index will be flushed to the disk in the future.
5. close: the close operation on IndexWrite in lucene, which implicitly performs the flush operation, and then performs the commit operation.

6. optimize (merge ),

It is a bit like disk fragmentation on a hard disk. To improve the search speed, it will reorganize the index and then remove the document to be deleted or updated. Note that solr does not have the update operation, only adding or deleting. During optimization, solr marks the index to be deleted or replaced as deleted, and then creates a new document to replace the index to be replaced. Optimize performs this operation. Therefore, during optimization, your index will increase and then decrease. The optimize operation will create a new index structure. Therefore, you need to prepare 2 times the size of the index when you commit.


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: 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.