Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

FieldCacheImpl#getTermsIndex: throw an exception when the field is not indexed and has unsorted doc values.

Adrien Grandf7db724186cb
diff --git a/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java b/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
index 11b08553fd9..2c5ea000bb4 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
@@ -1036,6 +1036,13 @@ class FieldCacheImpl implements FieldCache {
// per-thread by SegmentReader):
return valuesIn;
} else {
+ final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
+ if (info != null && !info.isIndexed() && info.hasDocValues()) {
+ // we don't try to build a sorted instance from numeric/binary doc
+ // values because dedup can be very costly
+ throw new IllegalArgumentException("Cannot get terms index for \"" + field
+ + "\": it isn't indexed and doesn't have sorted doc values");
+ }
return (SortedDocValues) caches.get(SortedDocValues.class).get(reader, new CacheKey(field, acceptableOverheadRatio), false);
}
}