title: How to seek to a term using a Lucene IndexReader?
body: <p>I'm trying to get a multi-phrased query to with a partial match. According to the <code>JavaDoc</code> for <code>MultiPhraseQuery</code>:</p>
  
  <blockquote>
    <p>A generalized version of PhraseQuery, with the possibility of adding more than one term at the same position that are treated as a disjunction (OR). To use this class to search for the phrase "Microsoft app*" first create a Builder and use MultiPhraseQuery.Builder.add(Term) on the term "microsoft" (assuming lowercase analysis), then find all terms that have "app" as prefix using LeafReader.terms(String), seeking to "app" then iterating and collecting terms until there is no longer that prefix, and finally use MultiPhraseQuery.Builder.add(Term[]) to add them. MultiPhraseQuery.Builder.build() returns the fully constructed (and immutable) MultiPhraseQuery.</p>
  </blockquote>
  
  <p><a href="https://lucene.apache.org/core/6_6_0/core/org/apache/lucene/search/MultiPhraseQuery.html" rel="nofollow noreferrer">https://lucene.apache.org/core/6_6_0/core/org/apache/lucene/search/MultiPhraseQuery.html</a></p>
  
  <p>I'm struggling with the part where it says:</p>
  
  <blockquote>
    <p>...find all terms that have "app" as prefix using LeafReader.terms(String), seeking to "app" then iterating and collecting terms until there is no longer that prefix...</p>
  </blockquote>
  
  <p>How does one seek over there terms? <code>LeafReader.terms(String)</code> gives you <code>Terms</code> which has an <code>iterator</code> method that gives you <code>TermsEnum</code> which you can <code>seek</code> with. I'm just not sure how extract matching terms using that?</p>