|
26 | 26 | import org.apache.lucene.index.SegmentInfos; |
27 | 27 | import org.apache.lucene.index.SegmentReader; |
28 | 28 | import org.apache.lucene.index.Terms; |
29 | | -import org.apache.lucene.index.TermsEnum; |
30 | 29 | import org.apache.lucene.search.IndexSearcher; |
31 | 30 | import org.apache.lucene.search.QueryCache; |
32 | 31 | import org.apache.lucene.search.QueryCachingPolicy; |
|
65 | 64 | import org.elasticsearch.index.codec.FieldInfosWithUsages; |
66 | 65 | import org.elasticsearch.index.codec.vectors.reflect.OffHeapByteSizeUtils; |
67 | 66 | import org.elasticsearch.index.mapper.DocumentParser; |
68 | | -import org.elasticsearch.index.mapper.FieldNamesFieldMapper; |
69 | 67 | import org.elasticsearch.index.mapper.LuceneDocument; |
70 | 68 | import org.elasticsearch.index.mapper.Mapper; |
71 | 69 | import org.elasticsearch.index.mapper.Mapping; |
@@ -385,14 +383,15 @@ protected final SparseVectorStats sparseVectorStats(IndexReader indexReader, Lis |
385 | 383 |
|
386 | 384 | private long getSparseVectorValueCount(final LeafReader atomicReader, List<BytesRef> fields) throws IOException { |
387 | 385 | long count = 0; |
388 | | - Terms terms = atomicReader.terms(FieldNamesFieldMapper.NAME); |
389 | | - if (terms == null) { |
390 | | - return count; |
391 | | - } |
392 | | - TermsEnum termsEnum = terms.iterator(); |
393 | | - for (var fieldName : fields) { |
394 | | - if (termsEnum.seekExact(fieldName)) { |
395 | | - count += termsEnum.docFreq(); |
| 386 | + for (var fieldNameBR : fields) { |
| 387 | + var fieldName = fieldNameBR.utf8ToString(); |
| 388 | + var fi = atomicReader.getFieldInfos().fieldInfo(fieldName); |
| 389 | + if (fi == null) { |
| 390 | + continue; |
| 391 | + } |
| 392 | + Terms terms = atomicReader.terms(fieldName); |
| 393 | + if (terms != null) { |
| 394 | + count += terms.getDocCount(); |
396 | 395 | } |
397 | 396 | } |
398 | 397 | return count; |
|
0 commit comments