Index: lucene/CHANGES.txt
===================================================================
--- lucene/CHANGES.txt	(revision 1363879)
+++ lucene/CHANGES.txt	(working copy)
@@ -68,6 +68,10 @@
 
 Bug Fixes
 
+* LUCENE-4242: When creating uninverted cache, normalize the TermEnum.docFreq()
+  so that terms are not excluded when there is a high ratio of deleted docs
+  in the index.
+
 * LUCENE-4176: Fix AnalyzingQueryParser to analyze range endpoints as bytes,
   so that it works correctly with Analyzers that produce binary non-UTF-8 terms
   such as CollationAnalyzer. (Nattapong Sirilappanich via Robert Muir) 
Index: lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java	(revision 1363879)
+++ lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java	(working copy)
@@ -296,6 +296,10 @@
     int termNum = 0;
     docsEnum = null;
 
+    
+    float offsetDeletedDocs = Math.min(1.0f, (float) reader.numDeletedDocs() / Math.max(reader.numDocs(), 1));
+    float maxTermDocFreq = (float) this.maxTermDocFreq;
+    
     // Loop begins with te positioned to first term (we call
     // seek above):
     for (;;) {
@@ -330,8 +334,9 @@
         // and 2) use FST not array/PagedBytes
         indexedTerms.add(indexedTerm);
       }
-
-      final int df = te.docFreq();
+      
+      
+      final float df = te.docFreq() * offsetDeletedDocs;
       if (df <= maxTermDocFreq) {
 
         docsEnum = te.docs(liveDocs, docsEnum, false);
