title: How does lucene index documents?
body: <p>I read some document about Lucene; also I read the document in this link
  (<a href="http://lucene.sourceforge.net/talks/pisa" rel="noreferrer">http://lucene.sourceforge.net/talks/pisa</a>).</p>
  
  <p>I don't really understand how Lucene indexes documents and don't understand which algorithms Lucene uses for indexing?</p>
  
  <p>On the above link, it says Lucene uses this algorithm for indexing:</p>
  
  <blockquote>
    <ul>
    <li>incremental algorithm:
    
    <ul>
    <li>maintain a stack of segment indices</li>
    <li>create index for each incoming document</li>
    <li>push new indexes onto the stack</li>
    <li>let b=10 be the merge factor; M=8</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <hr>
  
  <pre><code>for (size = 1; size &lt; M; size *= b) {
      if (there are b indexes with size docs on top of the stack) {
          pop them off the stack;
          merge them into a single index;
          push the merged index onto the stack;
      } else {
          break;
      }
  }
  </code></pre>
  
  <p>How does this algorithm provide optimized indexing?</p>
  
  <p>Does Lucene use B-tree algorithm or any other algorithm like that for indexing 
  - or does it have a particular algorithm?</p>