读书人

Lucene/Solr Dev 二 : Indexing and S

发布时间: 2012-09-24 13:49:41 作者: rapoo

Lucene/Solr Dev 2 : Indexing and Searching Simultaneously

Abstract

?? First i give my conclusion: Lucene can index and search simultaneously, what's more, we can only index one document and then we?can search this document at once.?Sounds cool,?but to do?like this?is necessary or useful? The answer is NO.? To account for the detail reason, we should first delve into Lucene Buffering and Flushing mechanism.

?

Lucene Buffering and Flushing

?


Lucene/Solr Dev 二 : Indexing and Searching Simultaneously
?

As shown in the above figure, when new Documents are add to a Lucene Index, or deletions are pending, they're initially buffered in memory?instead of being immediately written to the disk. This is done for performance, to minimize disk IO. Periodcally, this changes are flushed to the index Directory as a new segment. The flush can be triggered by IndexWriter according to the below three criteria:

1. To flush when the buffer has consumed more then a pre-set amount of RAM, we can use the below method to set the buffer size:

?

through the table we can get the conclusion.

?

Conclusion

Lucene indexing and searching simultaneous is possible, only has the IndexWriter's commit() method called and the IndexReader is reopened. in order to keep lucene performance, we?should?not do commit more frequently, the best choice is more than 500 Documents has added to the index directory we call the commit method.?

?

PS : for some reason, the most is my english is not so proficient, so some of my viewpoint is not state clearly, Welcome your comments to made the view more clearly.

?

?

?

?

?

?

?

?

?

?

?

读书人网 >软件架构设计

热点推荐