diff --git lucene/suggest/src/java/org/apache/lucene/search/spell/Dictionary.java lucene/suggest/src/java/org/apache/lucene/search/spell/Dictionary.java
index d1ed4e7..59194b8 100644
--- lucene/suggest/src/java/org/apache/lucene/search/spell/Dictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/spell/Dictionary.java
@@ -17,19 +17,20 @@ package org.apache.lucene.search.spell;
  */
 
 import java.io.IOException;
-import org.apache.lucene.util.BytesRefIterator;
+
+import org.apache.lucene.search.suggest.InputIterator;
 
 /**
  * A simple interface representing a Dictionary. A Dictionary
- * here is just a list of words.
+ * here is a list of entries, where every entry consists of
+ * term, weight and payload.
  * 
- *
  */
 public interface Dictionary {
 
   /**
-   * Return all words present in the dictionary
+   * Returns an iterator over all the entries
    * @return Iterator
    */
-  BytesRefIterator getWordsIterator() throws IOException;
+  InputIterator getEntryIterator() throws IOException;
 }
diff --git lucene/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java lucene/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java
index 826ba28..54c239f 100644
--- lucene/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/spell/HighFrequencyDictionary.java
@@ -56,7 +56,7 @@ public class HighFrequencyDictionary implements Dictionary {
   }
 
   @Override
-  public final BytesRefIterator getWordsIterator() throws IOException {
+  public final InputIterator getEntryIterator() throws IOException {
     return new HighFrequencyIterator();
   }
 
@@ -65,6 +65,7 @@ public class HighFrequencyDictionary implements Dictionary {
     private final TermsEnum termsEnum;
     private int minNumDocs;
     private long freq;
+    private int count = 0;
 
     HighFrequencyIterator() throws IOException {
       Terms terms = MultiFields.getTerms(reader, field);
@@ -93,6 +94,7 @@ public class HighFrequencyDictionary implements Dictionary {
           if (isFrequent(termsEnum.docFreq())) {
             freq = termsEnum.docFreq();
             spare.copyBytes(next);
+            count++;
             return spare;
           }
         }
@@ -109,5 +111,10 @@ public class HighFrequencyDictionary implements Dictionary {
     public boolean hasPayloads() {
       return false;
     }
+
+    @Override
+    public int getCount() {
+      return count;
+    }
   }
 }
diff --git lucene/suggest/src/java/org/apache/lucene/search/spell/LuceneDictionary.java lucene/suggest/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
index b5d6627..d55e5bb 100644
--- lucene/suggest/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
@@ -18,6 +18,7 @@ package org.apache.lucene.search.spell;
  */
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.suggest.InputIterator;
 import org.apache.lucene.util.BytesRefIterator;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.MultiFields;
@@ -42,12 +43,12 @@ public class LuceneDictionary implements Dictionary {
   }
 
   @Override
-  public final BytesRefIterator getWordsIterator() throws IOException {
+  public final InputIterator getEntryIterator() throws IOException {
     final Terms terms = MultiFields.getTerms(reader, field);
     if (terms != null) {
-      return terms.iterator(null);
+      return new InputIterator.InputIteratorWrapper(terms.iterator(null));
     } else {
-      return BytesRefIterator.EMPTY;
+      return InputIterator.EMPTY;
     }
   }
 }
diff --git lucene/suggest/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java lucene/suggest/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java
index 7071ff7..5e77021 100644
--- lucene/suggest/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 
+import org.apache.lucene.search.suggest.InputIterator;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefIterator;
 import org.apache.lucene.util.IOUtils;
@@ -66,8 +67,8 @@ public class PlainTextDictionary implements Dictionary {
   }
 
   @Override
-  public BytesRefIterator getWordsIterator() throws IOException {
-    return new FileIterator();
+  public InputIterator getEntryIterator() throws IOException {
+    return new InputIterator.InputIteratorWrapper(new FileIterator());
   }
 
   final class FileIterator implements BytesRefIterator {
diff --git lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
index 6f5f399..e61a287 100644
--- lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
+++ lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
@@ -512,7 +512,7 @@ public class SpellChecker implements java.io.Closeable {
       boolean isEmpty = termsEnums.isEmpty();
 
       try { 
-        BytesRefIterator iter = dict.getWordsIterator();
+        BytesRefIterator iter = dict.getEntryIterator();
         BytesRef currentTerm;
         
         terms: while ((currentTerm = iter.next()) != null) {
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/BufferedInputIterator.java lucene/suggest/src/java/org/apache/lucene/search/suggest/BufferedInputIterator.java
index b9772fa..8d2c752 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/BufferedInputIterator.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/BufferedInputIterator.java
@@ -40,6 +40,7 @@ public class BufferedInputIterator implements InputIterator {
   private final BytesRef spare = new BytesRef();
   private final BytesRef payloadSpare = new BytesRef();
   private final boolean hasPayloads;
+  private int count = 0;
   
   /** Creates a new iterator, buffering entries from the specified iterator */
   public BufferedInputIterator(InputIterator source) throws IOException {
@@ -68,6 +69,7 @@ public class BufferedInputIterator implements InputIterator {
   public BytesRef next() throws IOException {
     if (++curPos < entries.size()) {
       entries.get(spare, curPos);
+      count++;
       return spare;
     }
     return null;
@@ -85,4 +87,9 @@ public class BufferedInputIterator implements InputIterator {
   public boolean hasPayloads() {
     return hasPayloads;
   }
+
+  @Override
+  public int getCount() {
+    return count;
+  }
 }
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentDictionary.java lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentDictionary.java
index d948e20..7648e95 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentDictionary.java
@@ -86,7 +86,7 @@ public class DocumentDictionary implements Dictionary {
   }
   
   @Override
-  public BytesRefIterator getWordsIterator() throws IOException {
+  public InputIterator getEntryIterator() throws IOException {
     return new DocumentInputIterator(payloadField!=null);
   }
 
@@ -101,7 +101,7 @@ public class DocumentDictionary implements Dictionary {
     private long currentWeight = 0;
     private BytesRef currentPayload = null;
     private final NumericDocValues weightValues;
-    
+    private int count = 0;
     
     /**
      * Creates an iterator over term, weight and payload fields from the lucene
@@ -150,7 +150,8 @@ public class DocumentDictionary implements Dictionary {
         
         currentPayload = tempPayload;
         currentWeight = getWeight(doc, currentDocId);
-
+        
+        count++;
         return tempTerm;
       }
       return null;
@@ -165,6 +166,11 @@ public class DocumentDictionary implements Dictionary {
     public boolean hasPayloads() {
       return hasPayloads;
     }
+    
+    @Override
+    public int getCount() {
+      return count;
+    }
 
     /** 
      * Returns the value of the <code>weightField</code> for the current document.
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentExpressionDictionary.java lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentExpressionDictionary.java
index 2834851..703dc05 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentExpressionDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentExpressionDictionary.java
@@ -126,7 +126,7 @@ public class DocumentExpressionDictionary extends DocumentDictionary {
   }
   
   @Override
-  public BytesRefIterator getWordsIterator() throws IOException {
+  public InputIterator getEntryIterator() throws IOException {
     return new DocumentExpressionInputIterator(payloadField!=null);
   }
   
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/FileDictionary.java lucene/suggest/src/java/org/apache/lucene/search/suggest/FileDictionary.java
index 5e59685..d954292 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/FileDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/FileDictionary.java
@@ -106,7 +106,7 @@ public class FileDictionary implements Dictionary {
   }
 
   @Override
-  public InputIterator getWordsIterator() {
+  public InputIterator getEntryIterator() {
     try {
       return new FileIterator();
     } catch (IOException e) {
@@ -120,6 +120,7 @@ public class FileDictionary implements Dictionary {
     private BytesRef curPayload = new BytesRef();
     private boolean isFirstLine = true;
     private boolean hasPayloads = false;
+    private int count = 0;
     
     private FileIterator() throws IOException {
       line = in.readLine();
@@ -157,6 +158,7 @@ public class FileDictionary implements Dictionary {
       }
       if (isFirstLine) {
         isFirstLine = false;
+        count++;
         return spare;
       }
       line = in.readLine();
@@ -183,6 +185,7 @@ public class FileDictionary implements Dictionary {
             curPayload = new BytesRef();
           }
         }
+        count++;
         return spare;
       } else {
         done = true;
@@ -209,5 +212,10 @@ public class FileDictionary implements Dictionary {
         curWeight = (long)Double.parseDouble(weight);
       }
     }
+
+    @Override
+    public int getCount() {
+      return count;
+    }
   }
 }
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/InputIterator.java lucene/suggest/src/java/org/apache/lucene/search/suggest/InputIterator.java
index bda1332..4292ac9 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/InputIterator.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/InputIterator.java
@@ -44,6 +44,12 @@ public interface InputIterator extends BytesRefIterator {
   /** Returns true if the iterator has payloads */
   public boolean hasPayloads();
   
+  /** Returns number of entries seen by the iterator so far */
+  public int getCount();
+  
+  /** Singleton InputIterator that iterates over 0 BytesRefs. */
+  public static final InputIterator EMPTY = new InputIteratorWrapper(BytesRefIterator.EMPTY);
+  
   /**
    * Wraps a BytesRefIterator as a suggester InputIterator, with all weights
    * set to <code>1</code> and carries no payload
@@ -79,5 +85,10 @@ public interface InputIterator extends BytesRefIterator {
     public boolean hasPayloads() {
       return false;
     }
+
+    @Override
+    public int getCount() {
+      return 0;
+    }
   }
 }
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/Lookup.java lucene/suggest/src/java/org/apache/lucene/search/suggest/Lookup.java
index 3b4e09c..75f0a77 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/Lookup.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/Lookup.java
@@ -155,23 +155,20 @@ public abstract class Lookup {
    * or unsorted keys from the dictionary's iterator - use
    * {@link SortedInputIterator} or
    * {@link UnsortedInputIterator} in such case.
+   * 
+   * Returns number of entries used to build the lookup
    */
-  public void build(Dictionary dict) throws IOException {
-    BytesRefIterator it = dict.getWordsIterator();
-    InputIterator tfit;
-    if (it instanceof InputIterator) {
-      tfit = (InputIterator)it;
-    } else {
-      tfit = new InputIterator.InputIteratorWrapper(it);
-    }
-    build(tfit);
+  public int build(Dictionary dict) throws IOException {
+    return build(dict.getEntryIterator());
   }
   
   /**
    * Builds up a new internal {@link Lookup} representation based on the given {@link InputIterator}.
    * The implementation might re-sort the data internally.
+   *
+   * Returns number of entries used to build the lookup
    */
-  public abstract void build(InputIterator tfit) throws IOException;
+  public abstract int build(InputIterator tfit) throws IOException;
   
   /**
    * Look up a key and return possible completion for this key.
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/SortedInputIterator.java lucene/suggest/src/java/org/apache/lucene/search/suggest/SortedInputIterator.java
index d804f38..28026b9 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/SortedInputIterator.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/SortedInputIterator.java
@@ -42,6 +42,7 @@ public class SortedInputIterator implements InputIterator {
   private final Comparator<BytesRef> comparator;
   private final boolean hasPayloads;
   private boolean done = false;
+  private int count = 0;
   
   private long weight;
   private final BytesRef scratch = new BytesRef();
@@ -80,6 +81,7 @@ public class SortedInputIterator implements InputIterator {
           payload = decodePayload(scratch, input);
         }
         success = true;
+        count++;
         return scratch;
       }
       close();
@@ -110,6 +112,11 @@ public class SortedInputIterator implements InputIterator {
   public boolean hasPayloads() {
     return hasPayloads;
   }
+  
+  @Override
+  public int getCount() {
+    return count;
+  }
 
   /** Sortes by BytesRef (ascending) then cost (ascending). */
   private final Comparator<BytesRef> tieBreakByCostComparator = new Comparator<BytesRef>() {
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
index 0cf4212..ca0326b 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
@@ -180,7 +180,7 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable {
   }
 
   @Override
-  public void build(InputIterator iter) throws IOException {
+  public int build(InputIterator iter) throws IOException {
 
     if (searcher != null) {
       searcher.getIndexReader().close();
@@ -314,6 +314,7 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable {
         IOUtils.closeWhileHandlingException(w, w2, r, dirTmp);
       }
     }
+    return iter.getCount();
   }
 
   /**
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java
index 4278440..7130631 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java
@@ -379,7 +379,7 @@ public class AnalyzingSuggester extends Lookup {
   }
 
   @Override
-  public void build(InputIterator iterator) throws IOException {
+  public int build(InputIterator iterator) throws IOException {
     String prefix = getClass().getSimpleName();
     File directory = Sort.defaultTempDir();
     File tempInput = File.createTempFile(prefix, ".input", directory);
@@ -568,6 +568,7 @@ public class AnalyzingSuggester extends Lookup {
       tempInput.delete();
       tempSorted.delete();
     }
+    return iterator.getCount();
   }
 
   @Override
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java
index e901ef7..da414e6 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FreeTextSuggester.java
@@ -274,14 +274,14 @@ public class FreeTextSuggester extends Lookup {
   }
 
   @Override
-  public void build(InputIterator iterator) throws IOException {
-    build(iterator, IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB);
+  public int build(InputIterator iterator) throws IOException {
+    return build(iterator, IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB);
   }
 
   /** Build the suggest index, using up to the specified
    *  amount of temporary RAM while building.  Note that
    *  the weights for the suggestions are ignored. */
-  public void build(InputIterator iterator, double ramBufferSizeMB) throws IOException {
+  public int build(InputIterator iterator, double ramBufferSizeMB) throws IOException {
     if (iterator.hasPayloads()) {
       throw new IllegalArgumentException("payloads are not supported");
     }
@@ -394,6 +394,7 @@ public class FreeTextSuggester extends Lookup {
         dir.close();
       }
     }
+    return iterator.getCount();
   }
 
   @Override
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
index 7c88a3e..d35eb71 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
@@ -140,8 +140,8 @@ public class FSTCompletionLookup extends Lookup {
   }
 
   @Override
-  public void build(InputIterator tfit) throws IOException {
-    if (tfit.hasPayloads()) {
+  public int build(InputIterator iterator) throws IOException {
+    if (iterator.hasPayloads()) {
       throw new IllegalArgumentException("this suggester doesn't support payloads");
     }
     File tempInput = File.createTempFile(
@@ -160,13 +160,13 @@ public class FSTCompletionLookup extends Lookup {
       byte [] buffer = new byte [0];
       ByteArrayDataOutput output = new ByteArrayDataOutput(buffer);
       BytesRef spare;
-      while ((spare = tfit.next()) != null) {
+      while ((spare = iterator.next()) != null) {
         if (spare.length + 4 >= buffer.length) {
           buffer = ArrayUtil.grow(buffer, spare.length + 4);
         }
 
         output.reset(buffer);
-        output.writeInt(encodeWeight(tfit.weight()));
+        output.writeInt(encodeWeight(iterator.weight()));
         output.writeBytes(spare.bytes, spare.offset, spare.length);
         writer.write(buffer, 0, output.getPosition());
       }
@@ -224,6 +224,7 @@ public class FSTCompletionLookup extends Lookup {
       tempInput.delete();
       tempSorted.delete();
     }
+    return iterator.getCount();
   }
   
   /** weight -> cost */
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/WFSTCompletionLookup.java lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/WFSTCompletionLookup.java
index eaff404..290fd38 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/WFSTCompletionLookup.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/WFSTCompletionLookup.java
@@ -92,7 +92,7 @@ public class WFSTCompletionLookup extends Lookup {
   }
   
   @Override
-  public void build(InputIterator iterator) throws IOException {
+  public int build(InputIterator iterator) throws IOException {
     if (iterator.hasPayloads()) {
       throw new IllegalArgumentException("this suggester doesn't support payloads");
     }
@@ -116,6 +116,7 @@ public class WFSTCompletionLookup extends Lookup {
       previous.copyBytes(scratch);
     }
     fst = builder.finish();
+    return iter.getCount();
   }
 
   
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java
index 65c4532..273480d 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java
@@ -52,8 +52,8 @@ public class JaspellLookup extends Lookup {
   public JaspellLookup() {}
 
   @Override
-  public void build(InputIterator tfit) throws IOException {
-    if (tfit.hasPayloads()) {
+  public int build(InputIterator iterator) throws IOException {
+    if (iterator.hasPayloads()) {
       throw new IllegalArgumentException("this suggester doesn't support payloads");
     }
     trie = new JaspellTernarySearchTrie();
@@ -61,8 +61,8 @@ public class JaspellLookup extends Lookup {
     BytesRef spare;
     final CharsRef charsSpare = new CharsRef();
 
-    while ((spare = tfit.next()) != null) {
-      final long weight = tfit.weight();
+    while ((spare = iterator.next()) != null) {
+      final long weight = iterator.weight();
       if (spare.length == 0) {
         continue;
       }
@@ -70,6 +70,7 @@ public class JaspellLookup extends Lookup {
       UnicodeUtil.UTF8toUTF16(spare.bytes, spare.offset, spare.length, charsSpare);
       trie.put(charsSpare.toString(), Long.valueOf(weight));
     }
+    return iterator.getCount();
   }
 
   /** 
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java
index 59cd5f9..bc39064 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java
@@ -51,26 +51,27 @@ public class TSTLookup extends Lookup {
   public TSTLookup() {}
 
   @Override
-  public void build(InputIterator tfit) throws IOException {
-    if (tfit.hasPayloads()) {
+  public int build(InputIterator iterator) throws IOException {
+    if (iterator.hasPayloads()) {
       throw new IllegalArgumentException("this suggester doesn't support payloads");
     }
     root = new TernaryTreeNode();
 
     // make sure it's sorted and the comparator uses UTF16 sort order
-    tfit = new SortedInputIterator(tfit, BytesRef.getUTF8SortedAsUTF16Comparator());
+    iterator = new SortedInputIterator(iterator, BytesRef.getUTF8SortedAsUTF16Comparator());
 
     ArrayList<String> tokens = new ArrayList<String>();
     ArrayList<Number> vals = new ArrayList<Number>();
     BytesRef spare;
     CharsRef charsSpare = new CharsRef();
-    while ((spare = tfit.next()) != null) {
+    while ((spare = iterator.next()) != null) {
       charsSpare.grow(spare.length);
       UnicodeUtil.UTF8toUTF16(spare.bytes, spare.offset, spare.length, charsSpare);
       tokens.add(charsSpare.toString());
-      vals.add(Long.valueOf(tfit.weight()));
+      vals.add(Long.valueOf(iterator.weight()));
     }
     autocomplete.balancedTree(tokens.toArray(), vals.toArray(), 0, tokens.size() - 1, root);
+    return iterator.getCount();
   }
 
   /** 
diff --git lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
index 35ed90c..48bdb7b 100644
--- lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
+++ lucene/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
@@ -90,7 +90,7 @@ public class TestLuceneDictionary extends LuceneTestCase {
       indexReader = DirectoryReader.open(store);
 
       ld = new LuceneDictionary(indexReader, "nonexistent_field");
-      it = ld.getWordsIterator();
+      it = ld.getEntryIterator();
 
       assertNull("More elements than expected", spare = it.next());
     } finally {
@@ -103,7 +103,7 @@ public class TestLuceneDictionary extends LuceneTestCase {
       indexReader = DirectoryReader.open(store);
 
       ld = new LuceneDictionary(indexReader, "aaa");
-      it = ld.getWordsIterator();
+      it = ld.getEntryIterator();
       assertNotNull("First element doesn't exist.", spare = it.next());
       assertTrue("First element isn't correct", spare.utf8ToString().equals("foo"));
       assertNull("More elements than expected", it.next());
@@ -117,7 +117,7 @@ public class TestLuceneDictionary extends LuceneTestCase {
       indexReader = DirectoryReader.open(store);
 
       ld = new LuceneDictionary(indexReader, "contents");
-      it = ld.getWordsIterator();
+      it = ld.getEntryIterator();
 
       assertNotNull("First element doesn't exist.", spare = it.next());
       assertTrue("First element isn't correct", spare.utf8ToString().equals("Jerry"));
@@ -126,7 +126,7 @@ public class TestLuceneDictionary extends LuceneTestCase {
       assertNull("More elements than expected", it.next());
 
       ld = new LuceneDictionary(indexReader, "contents");
-      it = ld.getWordsIterator();
+      it = ld.getEntryIterator();
 
       int counter = 2;
       while (it.next() != null) {
@@ -145,7 +145,7 @@ public class TestLuceneDictionary extends LuceneTestCase {
       indexReader = DirectoryReader.open(store);
 
       ld = new LuceneDictionary(indexReader, "contents");
-      it = ld.getWordsIterator();
+      it = ld.getEntryIterator();
 
       // just iterate through words
       assertEquals("First element isn't correct", "Jerry", it.next().utf8ToString());
@@ -162,7 +162,7 @@ public class TestLuceneDictionary extends LuceneTestCase {
       indexReader = DirectoryReader.open(store);
 
       ld = new LuceneDictionary(indexReader, "zzz");
-      it = ld.getWordsIterator();
+      it = ld.getEntryIterator();
 
       assertNotNull("First element doesn't exist.", spare = it.next());
       assertEquals("First element isn't correct", "bar", spare.utf8ToString());
diff --git lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java
index 9e5d8e8..c0a5185 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java
@@ -109,7 +109,7 @@ public class DocumentDictionaryTest extends LuceneTestCase {
     writer.close();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME, PAYLOAD_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
 
     assertNull(inputIterator.next());
     assertEquals(inputIterator.weight(), 0);
@@ -135,7 +135,7 @@ public class DocumentDictionaryTest extends LuceneTestCase {
     writer.close();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME, PAYLOAD_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
     BytesRef f;
     while((f = inputIterator.next())!=null) {
       Document doc = docs.remove(f.utf8ToString());
@@ -170,7 +170,7 @@ public class DocumentDictionaryTest extends LuceneTestCase {
     writer.close();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
     BytesRef f;
     while((f = inputIterator.next())!=null) {
       Document doc = docs.remove(f.utf8ToString());
@@ -228,7 +228,7 @@ public class DocumentDictionaryTest extends LuceneTestCase {
     IndexReader ir = DirectoryReader.open(dir);
     assertEquals(ir.numDocs(), docs.size());
     Dictionary dictionary = new DocumentDictionary(ir, FIELD_NAME, WEIGHT_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
     BytesRef f;
     while((f = inputIterator.next())!=null) {
       Document doc = docs.remove(f.utf8ToString());
diff --git lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java
index 30cb837..6010c93 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentExpressionDictionaryTest.java
@@ -87,7 +87,7 @@ public class DocumentExpressionDictionaryTest extends LuceneTestCase {
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_2, SortField.Type.LONG));
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_3, SortField.Type.LONG));
     Dictionary dictionary = new DocumentExpressionDictionary(ir, FIELD_NAME, "((w1 + w2) - w3)", sortFields, PAYLOAD_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
 
     assertNull(inputIterator.next());
     assertEquals(inputIterator.weight(), 0);
@@ -116,7 +116,7 @@ public class DocumentExpressionDictionaryTest extends LuceneTestCase {
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_2, SortField.Type.LONG));
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_3, SortField.Type.LONG));
     Dictionary dictionary = new DocumentExpressionDictionary(ir, FIELD_NAME, "((w1 + w2) - w3)", sortFields, PAYLOAD_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
     BytesRef f;
     while((f = inputIterator.next())!=null) {
       Document doc = docs.remove(f.utf8ToString());
@@ -151,7 +151,7 @@ public class DocumentExpressionDictionaryTest extends LuceneTestCase {
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_2, SortField.Type.LONG));
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_3, SortField.Type.LONG));
     Dictionary dictionary = new DocumentExpressionDictionary(ir, FIELD_NAME, "w1 + (0.2 * w2) - (w3 - w1)/2", sortFields);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
     BytesRef f;
     while((f = inputIterator.next())!=null) {
       Document doc = docs.remove(f.utf8ToString());
@@ -206,7 +206,7 @@ public class DocumentExpressionDictionaryTest extends LuceneTestCase {
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_1, SortField.Type.LONG));
     sortFields.add(new SortField(WEIGHT_FIELD_NAME_2, SortField.Type.LONG));
     Dictionary dictionary = new DocumentExpressionDictionary(ir, FIELD_NAME, "w2-w1", sortFields, PAYLOAD_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
     BytesRef f;
     while((f = inputIterator.next())!=null) {
       Document doc = docs.remove(f.utf8ToString());
@@ -237,7 +237,7 @@ public class DocumentExpressionDictionaryTest extends LuceneTestCase {
 
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new DocumentExpressionDictionary(ir, FIELD_NAME, new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
-    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    InputIterator inputIterator = dictionary.getEntryIterator();
     BytesRef f;
     while((f = inputIterator.next())!=null) {
       Document doc = docs.remove(f.utf8ToString());
diff --git lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java
index fbeb6df..665af98 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java
@@ -76,7 +76,7 @@ public class FileDictionaryTest extends LuceneTestCase {
     InputStream inputReader = new ByteArrayInputStream(fileInput.getValue().getBytes("UTF-8"));
     FileDictionary dictionary = new FileDictionary(inputReader);
     List<List<String>> entries = fileInput.getKey();
-    InputIterator inputIter = dictionary.getWordsIterator();
+    InputIterator inputIter = dictionary.getEntryIterator();
     assertFalse(inputIter.hasPayloads());
     BytesRef term;
     int count = 0;
@@ -98,7 +98,7 @@ public class FileDictionaryTest extends LuceneTestCase {
     InputStream inputReader = new ByteArrayInputStream(fileInput.getValue().getBytes("UTF-8"));
     FileDictionary dictionary = new FileDictionary(inputReader);
     List<List<String>> entries = fileInput.getKey();
-    InputIterator inputIter = dictionary.getWordsIterator();
+    InputIterator inputIter = dictionary.getEntryIterator();
     assertFalse(inputIter.hasPayloads());
     BytesRef term;
     int count = 0;
@@ -120,7 +120,7 @@ public class FileDictionaryTest extends LuceneTestCase {
     InputStream inputReader = new ByteArrayInputStream(fileInput.getValue().getBytes("UTF-8"));
     FileDictionary dictionary = new FileDictionary(inputReader);
     List<List<String>> entries = fileInput.getKey();
-    InputIterator inputIter = dictionary.getWordsIterator();
+    InputIterator inputIter = dictionary.getEntryIterator();
     assertTrue(inputIter.hasPayloads());
     BytesRef term;
     int count = 0;
@@ -146,7 +146,7 @@ public class FileDictionaryTest extends LuceneTestCase {
     InputStream inputReader = new ByteArrayInputStream(fileInput.getValue().getBytes("UTF-8"));
     FileDictionary dictionary = new FileDictionary(inputReader);
     List<List<String>> entries = fileInput.getKey();
-    InputIterator inputIter = dictionary.getWordsIterator();
+    InputIterator inputIter = dictionary.getEntryIterator();
     assertTrue(inputIter.hasPayloads());
     BytesRef term;
     int count = 0;
@@ -173,7 +173,7 @@ public class FileDictionaryTest extends LuceneTestCase {
     InputStream inputReader = new ByteArrayInputStream(fileInput.getValue().getBytes("UTF-8"));
     FileDictionary dictionary = new FileDictionary(inputReader, " , ");
     List<List<String>> entries = fileInput.getKey();
-    InputIterator inputIter = dictionary.getWordsIterator();
+    InputIterator inputIter = dictionary.getEntryIterator();
     assertTrue(inputIter.hasPayloads());
     BytesRef term;
     int count = 0;
diff --git lucene/suggest/src/test/org/apache/lucene/search/suggest/InputArrayIterator.java lucene/suggest/src/test/org/apache/lucene/search/suggest/InputArrayIterator.java
index edebb37..2cd510e 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/InputArrayIterator.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/InputArrayIterator.java
@@ -30,6 +30,7 @@ public final class InputArrayIterator implements InputIterator {
   private final boolean hasPayloads;
   private boolean first;
   private Input current;
+  private int count = 0;
   private final BytesRef spare = new BytesRef();
 
   public InputArrayIterator(Iterator<Input> i) {
@@ -64,6 +65,7 @@ public final class InputArrayIterator implements InputIterator {
         current = i.next();
       }
       spare.copyBytes(current.term);
+      count++;
       return spare;
     }
     return null;
@@ -78,4 +80,9 @@ public final class InputArrayIterator implements InputIterator {
   public boolean hasPayloads() {
     return hasPayloads;
   }
+
+  @Override
+  public int getCount() {
+    return count;
+  }
 }
\ No newline at end of file
diff --git lucene/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java lucene/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java
index 576d2a5..0d2d786 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/TestHighFrequencyDictionary.java
@@ -35,7 +35,7 @@ public class TestHighFrequencyDictionary extends LuceneTestCase {
     writer.close();
     IndexReader ir = DirectoryReader.open(dir);
     Dictionary dictionary = new HighFrequencyDictionary(ir, "bogus", 0.1f);
-    BytesRefIterator tf = dictionary.getWordsIterator();
+    BytesRefIterator tf = dictionary.getEntryIterator();
     assertNull(tf.next());
     dir.close();
   }
diff --git lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java
index e500d34..33a2848 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java
@@ -171,6 +171,11 @@ public class TestFreeTextSuggester extends LuceneTestCase {
         public boolean hasPayloads() {
           return false;
         }
+
+        @Override
+        public int getCount() {
+          return count;
+        }
       });
     if (VERBOSE) {
       System.out.println(sug.sizeInBytes() + " bytes");
@@ -362,6 +367,11 @@ public class TestFreeTextSuggester extends LuceneTestCase {
         public boolean hasPayloads() {
           return false;
         }
+
+        @Override
+        public int getCount() {
+          return upto;
+        }
       });
 
     // Build inefficient but hopefully correct model:
