List of usage examples for org.apache.lucene.index Terms getMax
@SuppressWarnings("fallthrough") public BytesRef getMax() throws IOException
From source file:com.github.flaxsearch.api.TermsData.java
License:Apache License
public TermsData(Terms terms, List<String> termsList, String encoding) throws IOException { this.termCount = terms.size(); this.docCount = terms.getDocCount(); this.minTerm = BytesRefUtils.encode(terms.getMin(), encoding); this.maxTerm = BytesRefUtils.encode(terms.getMax(), encoding); this.terms = termsList; }
From source file:com.rondhuit.w2v.lucene.LuceneIndexCorpus.java
License:Apache License
@Override public void learnVocab() throws IOException { super.learnVocab(); final String field = ((LuceneIndexConfig) config).getField(); final Terms terms = MultiFields.getTerms(reader, field); final BytesRef maxTerm = terms.getMax(); final BytesRef minTerm = terms.getMin(); Query q = new TermRangeQuery(field, minTerm, maxTerm, true, true); IndexSearcher searcher = new IndexSearcher(reader); topDocs = searcher.search(q, Integer.MAX_VALUE); TermsEnum termsEnum = null;/*from w w w. j a v a2s . c om*/ termsEnum = terms.iterator(termsEnum); termsEnum.seekCeil(new BytesRef()); BytesRef term = termsEnum.term(); while (term != null) { int p = addWordToVocab(term.utf8ToString()); vocab[p].setCn((int) termsEnum.totalTermFreq()); term = termsEnum.next(); } }
From source file:org.codelibs.elasticsearch.index.mapper.MappedFieldType.java
License:Apache License
/** * @return a {FieldStats} instance that maps to the type of this * field or {@code null} if the provided index has no stats about the * current field/*from w w w . jav a 2 s . com*/ */ public FieldStats stats(IndexReader reader) throws IOException { int maxDoc = reader.maxDoc(); FieldInfo fi = MultiFields.getMergedFieldInfos(reader).fieldInfo(name()); if (fi == null) { return null; } Terms terms = MultiFields.getTerms(reader, name()); if (terms == null) { return new FieldStats.Text(maxDoc, 0, -1, -1, isSearchable(), isAggregatable()); } FieldStats stats = new FieldStats.Text(maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), isSearchable(), isAggregatable(), terms.getMin(), terms.getMax()); return stats; }
From source file:org.elasticsearch.index.mapper.MappedFieldType.java
License:Apache License
/** * @return a {@link FieldStats} instance that maps to the type of this field based on the provided {@link Terms} instance. *///from ww w.j av a 2 s . c o m public FieldStats stats(Terms terms, int maxDoc) throws IOException { return new FieldStats.Text(maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), terms.getMin(), terms.getMax()); }