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..2fb6fbb 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentDictionary.java
@@ -26,6 +26,11 @@ import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.StorableField;
 import org.apache.lucene.index.StoredDocument;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.search.spell.Dictionary;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -34,7 +39,8 @@ import org.apache.lucene.util.BytesRefIterator;
 /**
  * <p>
  * Dictionary with terms, weights and optionally payload information 
- * taken from stored/indexed fields in a Lucene index.
+ * taken from stored/indexed fields in a Lucene index. The entries
+ * can be pruned by optionally providing a {@link Query}
  * </p>
  * <b>NOTE:</b> 
  *  <ul>
@@ -62,27 +68,47 @@ public class DocumentDictionary implements Dictionary {
   protected final String payloadField;
   private final String field;
   private final String weightField;
+  private final Query query;
   
   /**
-   * Creates a new dictionary with the contents of the fields named <code>field</code>
+   * Creates a new dictionary with the contents of the field named <code>field</code>
    * for the terms and <code>weightField</code> for the weights that will be used for
    * the corresponding terms.
    */
   public DocumentDictionary(IndexReader reader, String field, String weightField) {
-    this(reader, field, weightField, null);
+    this(reader, null, field, weightField, null);
   }
   
   /**
-   * Creates a new dictionary with the contents of the fields named <code>field</code>
+   * Creates a new dictionary with the contents of the field named <code>field</code>
+   * for the terms and <code>weightField</code> for the weights that will be used for
+   * the corresponding terms for every entry that gets returned upon executing <code>query</code>.
+   */
+  public DocumentDictionary(IndexReader reader, Query query, String field, String weightField) {
+    this(reader, query, field, weightField, null);
+  }
+  /**
+   * Creates a new dictionary with the contents of the field named <code>field</code>
    * for the terms, <code>weightField</code> for the weights that will be used for the 
    * the corresponding terms and <code>payloadField</code> for the corresponding payloads
    * for the entry.
    */
   public DocumentDictionary(IndexReader reader, String field, String weightField, String payloadField) {
+    this(reader, null, field, weightField, payloadField);
+  }
+  
+  /**
+   * Creates a new dictionary with the contents of the field named <code>field</code>
+   * for the terms, <code>weightField</code> for the weights that will be used for the 
+   * the corresponding terms and <code>payloadField</code> for the corresponding payloads
+   * for the entry for every entry that gets returned upon executing <code>query</code>
+   */
+  public DocumentDictionary(IndexReader reader, Query query, String field, String weightField, String payloadField) {
     this.reader = reader;
     this.field = field;
     this.weightField = weightField;
     this.payloadField = payloadField;
+    this.query = (query == null) ? new MatchAllDocsQuery() : query;
   }
   
   @Override
@@ -97,7 +123,8 @@ public class DocumentDictionary implements Dictionary {
     private final Set<String> relevantFields;
     private final boolean hasPayloads;
     private final Bits liveDocs;
-    private int currentDocId = -1;
+    private int currentIndex = -1;
+    private final ScoreDoc[] results;
     private long currentWeight = 0;
     private BytesRef currentPayload = null;
     private final NumericDocValues weightValues;
@@ -110,10 +137,20 @@ public class DocumentDictionary implements Dictionary {
      */
     public DocumentInputIterator(boolean hasPayloads) throws IOException {
       this.hasPayloads = hasPayloads;
-      docCount = reader.maxDoc() - 1;
-      weightValues = (weightField != null) ? MultiDocValues.getNumericValues(reader, weightField) : null;
-      liveDocs = (reader.leaves().size() > 0) ? MultiFields.getLiveDocs(reader) : null;
       relevantFields = getRelevantFields(new String [] {field, weightField, payloadField});
+      if (reader.maxDoc() == 0) { // no documents
+        weightValues = null;
+        liveDocs = null;
+        docCount = -1;
+        results = null;
+      } else {
+        weightValues = (weightField != null) ? MultiDocValues.getNumericValues(reader, weightField) : null;
+        liveDocs = (reader.leaves().size() > 0) ? MultiFields.getLiveDocs(reader) : null;
+        IndexSearcher searcher = new IndexSearcher(reader);
+        TopDocs topDocs = searcher.search(query, reader.maxDoc());
+        docCount = topDocs.scoreDocs.length - 1;
+        results = topDocs.scoreDocs;
+      }
     }
 
     @Override
@@ -123,8 +160,10 @@ public class DocumentDictionary implements Dictionary {
 
     @Override
     public BytesRef next() throws IOException {
-      while (currentDocId < docCount) {
-        currentDocId++;
+      while (currentIndex < docCount) {
+        currentIndex++;
+        ScoreDoc currentDoc = results[currentIndex];
+        int currentDocId = currentDoc.doc;
         if (liveDocs != null && !liveDocs.get(currentDocId)) { 
           continue;
         }
diff --git lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java
index cbc5763..77f00b2 100644
--- lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java
+++ lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java
@@ -27,6 +27,7 @@ import org.apache.lucene.index.ReaderUtil;
 import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.queries.function.FunctionValues;
 import org.apache.lucene.queries.function.ValueSource;
+import org.apache.lucene.search.Query;
 import org.apache.lucene.util.BytesRefIterator;
 
 
@@ -68,26 +69,45 @@ public class DocumentValueSourceDictionary extends DocumentDictionary {
   
   private final ValueSource weightsValueSource;
   
-  /**
+  /** 
    * Creates a new dictionary with the contents of the fields named <code>field</code>
-   * for the terms, <code>payloadField</code> for the corresponding payloads
-   * and uses the <code>weightsValueSource</code> supplied to determine the 
+   * for the terms and uses the <code>weightsValueSource</code> supplied to determine the 
    * score.
    */
   public DocumentValueSourceDictionary(IndexReader reader, String field,
-                                       ValueSource weightsValueSource, String payload) {
-    super(reader, field, null, payload);
-    this.weightsValueSource = weightsValueSource;  
+                                       ValueSource weightsValueSource) {
+    this(reader, null, field, weightsValueSource, null);  
   }
   
   /** 
    * Creates a new dictionary with the contents of the fields named <code>field</code>
    * for the terms and uses the <code>weightsValueSource</code> supplied to determine the 
-   * score.
+   * score for all the entries that gets returned for <code>query</code>.
    */
-  public DocumentValueSourceDictionary(IndexReader reader, String field,
+  public DocumentValueSourceDictionary(IndexReader reader, Query query, String field,
                                        ValueSource weightsValueSource) {
-    super(reader, field, null, null);
+    this(reader, query, field, weightsValueSource, null);  
+  }
+  
+  /** 
+   * Creates a new dictionary with the contents of the fields named <code>field</code>
+   * for the terms, <code>payloadField</code> for the corresponding payloads and 
+   * uses the <code>weightsValueSource</code> supplied to determine the score.
+   */
+  public DocumentValueSourceDictionary(IndexReader reader, String field,
+                                       ValueSource weightsValueSource, String payload) {
+    this(reader, null, field, weightsValueSource, payload);  
+  }
+  
+  /**
+   * Creates a new dictionary with the contents of the fields named <code>field</code>
+   * for the terms, <code>payloadField</code> for the corresponding payloads
+   * and uses the <code>weightsValueSource</code> supplied to determine the 
+   * score for all the entries that gets returned for <code>query</code>.
+   */
+  public DocumentValueSourceDictionary(IndexReader reader, Query query, String field,
+                                       ValueSource weightsValueSource, String payload) {
+    super(reader, query, field, null, payload);
     this.weightsValueSource = weightsValueSource;  
   }
   
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..37a8597 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentDictionaryTest.java
@@ -20,6 +20,7 @@ import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.StorableField;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.search.spell.Dictionary;
 import org.apache.lucene.search.suggest.DocumentDictionary;
 import org.apache.lucene.store.Directory;
@@ -99,6 +100,55 @@ public class DocumentDictionaryTest extends LuceneTestCase {
   }
   
   @Test
+  public void testQuery() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+    iwc.setMergePolicy(newLogMergePolicy());
+    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
+    Map<String, Document> filteredDocs = new HashMap<>();
+    
+    Document doc1 = new Document();
+    doc1.add(new TextField(FIELD_NAME, "filtered_1", Field.Store.YES));
+    doc1.add(new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_1")));
+    doc1.add(new StoredField(WEIGHT_FIELD_NAME, 100d));
+    writer.addDocument(doc1);
+    filteredDocs.put("filtered_1", doc1);
+    
+    Document doc2 = new Document();
+    doc2.add(new TextField(FIELD_NAME, "invalid_1", Field.Store.YES));
+    doc2.add(new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_2")));
+    doc2.add(new StoredField(WEIGHT_FIELD_NAME, 101d));
+    writer.addDocument(doc2);
+    
+    Document doc3 = new Document();
+    doc3.add(new TextField(FIELD_NAME, "filtered_2", Field.Store.YES));
+    doc3.add(new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_4")));
+    doc3.add(new StoredField(WEIGHT_FIELD_NAME, 102d));
+    writer.addDocument(doc3);
+    filteredDocs.put("filtered_2", doc3);
+    
+    writer.commit();
+    writer.close();
+    
+    IndexReader ir = DirectoryReader.open(dir);
+    WildcardQuery wildcardQuery = new WildcardQuery(new Term(FIELD_NAME, "filtered*"));
+    Dictionary dictionary = new DocumentDictionary(ir, wildcardQuery, FIELD_NAME, WEIGHT_FIELD_NAME, PAYLOAD_FIELD_NAME);
+    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    BytesRef f;
+    while((f = inputIterator.next()) != null) {
+      Document doc = filteredDocs.remove(f.utf8ToString());
+      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+      Field weightField = doc.getField(WEIGHT_FIELD_NAME);
+      assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
+      assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
+    }
+    assertTrue(filteredDocs.isEmpty());
+    
+    ir.close();
+    dir.close();
+  }
+  
+  @Test
   public void testEmptyReader() throws IOException {
     Directory dir = newDirectory();
     IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
diff --git lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java
index b1eef56..9bb9f87 100644
--- lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java
+++ lucene/suggest/src/test/org/apache/lucene/search/suggest/DocumentValueSourceDictionaryTest.java
@@ -37,6 +37,7 @@ import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource;
+import org.apache.lucene.search.PhraseQuery;
 import org.apache.lucene.queries.function.valuesource.LongFieldSource;
 import org.apache.lucene.queries.function.valuesource.SumFloatFunction;
 import org.apache.lucene.search.spell.Dictionary;
@@ -239,4 +240,35 @@ public class DocumentValueSourceDictionaryTest extends LuceneTestCase {
     dir.close();
   }
   
+  @Test
+  public void testWithQuery() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+    iwc.setMergePolicy(newLogMergePolicy());
+    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
+    Map<String, Document> docs = generateIndexDocuments(atLeast(100));
+    for(Document doc: docs.values()) {
+      writer.addDocument(doc);
+    }
+    writer.commit();
+    writer.close();
+
+    IndexReader ir = DirectoryReader.open(dir);
+    PhraseQuery phraseQuery = new PhraseQuery();
+    phraseQuery.add(new Term(FIELD_NAME, "field_1"));
+    ValueSource[] toAdd = new ValueSource[] {new LongFieldSource(WEIGHT_FIELD_NAME_1), new LongFieldSource(WEIGHT_FIELD_NAME_2)};
+    Dictionary dictionary = new DocumentValueSourceDictionary(ir, phraseQuery, FIELD_NAME, new SumFloatFunction(toAdd), PAYLOAD_FIELD_NAME);
+    InputIterator inputIterator = (InputIterator) dictionary.getWordsIterator();
+    BytesRef f = inputIterator.next();
+    Document doc = docs.remove("field_1");
+    long w1 = doc.getField(WEIGHT_FIELD_NAME_1).numericValue().longValue();
+    long w2 = doc.getField(WEIGHT_FIELD_NAME_2).numericValue().longValue();
+    assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
+    assertEquals(inputIterator.weight(), (w1 + w2));
+    assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
+    assertNull(inputIterator.next());
+    
+    ir.close();
+    dir.close();
+  }
 }
