org.apache.lucene.index.Terms#getMin ( )源码实例Demo

下面列出了org.apache.lucene.index.Terms#getMin ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: word2vec-lucene   文件: LuceneIndexCorpus.java
@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;
  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();
  }
}
 
源代码2 项目: lucene-solr   文件: LegacyNumericUtils.java
/**
 * Returns the minimum int value indexed into this
 * numeric field or null if no terms exist.
 */
public static Integer getMinInt(Terms terms) throws IOException {
  // All shift=0 terms are sorted first, so we don't need
  // to filter the incoming terms; we can just get the
  // min:
  BytesRef min = terms.getMin();
  return (min != null) ? LegacyNumericUtils.prefixCodedToInt(min) : null;
}
 
源代码3 项目: lucene-solr   文件: LegacyNumericUtils.java
/**
 * Returns the minimum long value indexed into this
 * numeric field or null if no terms exist.
 */
public static Long getMinLong(Terms terms) throws IOException {
  // All shift=0 terms are sorted first, so we don't need
  // to filter the incoming terms; we can just get the
  // min:
  BytesRef min = terms.getMin();
  return (min != null) ? LegacyNumericUtils.prefixCodedToLong(min) : null;
}
 
源代码4 项目: Elasticsearch   文件: MappedFieldType.java
/**
 * @return a {@link FieldStats} instance that maps to the type of this field based on the provided {@link Terms} instance.
 */
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    return new FieldStats.Text(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), terms.getMin(), terms.getMax()
    );
}