title: Retrieving all term positions from DocsAndPositionsEnum
body: <p>I am upgrading to Solr 4.1 and having trouble retrieving position and offset information using the new API.  My <strong>index</strong> comprises of one document with one field containing the string '<strong>one quick brown fox jumped over one lazy dog</strong>'. I am <strong>querying</strong> my index for <strong>'one'</strong> and trying to retrieve positions and offsets corresponding to 'one'.</p>
  
  <p>Here is the code snippet</p>
  
  <pre><code>Terms terms=reader.getTermVector(docId, fieldName);
  TermsEnum termsEnum= terms.iterator(TermsEnum.EMPTY);
      BytesRef term;
      while((term=termsEnum.next())!=null){
          String docTerm = term.utf8ToString();
          DocsAndPositionsEnum docPosEnum = termsEnum.docsAndPositions(null, null, DocsAndPositionsEnum.FLAG_OFFSETS);
          //Check if the current term is the same as the query term and if so
          //retrieve all positions (can be multiple occurrences of a term in a field) corresponding to the term
          if (queryTerms.contains(docTerm)) {
              int position;
              while((position=docPosEnum.nextPosition())!=-1){
                  int start=docPosEnum.startOffset();
                  int end=docPosEnum.endOffset();
                  //Store start, end and position in an a list
                  }
          }
      }
  </code></pre>
  
  <p>The inner while loop is incorrect. Any pointers on how to iterate through all positions in a DocsAndPositionsEnum will be greatly appreciated.</p>