|
25 | 25 | import org.apache.lucene.index.SegmentInfos; |
26 | 26 | import org.apache.lucene.index.SegmentReader; |
27 | 27 | import org.apache.lucene.index.Terms; |
28 | | -import org.apache.lucene.index.TermsEnum; |
29 | 28 | import org.apache.lucene.search.IndexSearcher; |
30 | 29 | import org.apache.lucene.search.QueryCache; |
31 | 30 | import org.apache.lucene.search.QueryCachingPolicy; |
|
61 | 60 | import org.elasticsearch.index.IndexVersion; |
62 | 61 | import org.elasticsearch.index.VersionType; |
63 | 62 | import org.elasticsearch.index.mapper.DocumentParser; |
64 | | -import org.elasticsearch.index.mapper.FieldNamesFieldMapper; |
65 | 63 | import org.elasticsearch.index.mapper.LuceneDocument; |
66 | 64 | import org.elasticsearch.index.mapper.Mapper; |
67 | 65 | import org.elasticsearch.index.mapper.Mapping; |
@@ -337,14 +335,15 @@ protected final SparseVectorStats sparseVectorStats(IndexReader indexReader, Lis |
337 | 335 |
|
338 | 336 | private long getSparseVectorValueCount(final LeafReader atomicReader, List<BytesRef> fields) throws IOException { |
339 | 337 | long count = 0; |
340 | | - Terms terms = atomicReader.terms(FieldNamesFieldMapper.NAME); |
341 | | - if (terms == null) { |
342 | | - return count; |
343 | | - } |
344 | | - TermsEnum termsEnum = terms.iterator(); |
345 | | - for (var fieldName : fields) { |
346 | | - if (termsEnum.seekExact(fieldName)) { |
347 | | - count += termsEnum.docFreq(); |
| 338 | + for (var fieldNameBR : fields) { |
| 339 | + var fieldName = fieldNameBR.utf8ToString(); |
| 340 | + var fi = atomicReader.getFieldInfos().fieldInfo(fieldName); |
| 341 | + if (fi == null) { |
| 342 | + continue; |
| 343 | + } |
| 344 | + Terms terms = atomicReader.terms(fieldName); |
| 345 | + if (terms != null) { |
| 346 | + count += terms.getDocCount(); |
348 | 347 | } |
349 | 348 | } |
350 | 349 | return count; |
|
0 commit comments