Example usage for org.apache.lucene.index Terms getMin

List of usage examples for org.apache.lucene.index Terms getMin

Introduction

In this page you can find the example usage for org.apache.lucene.index Terms getMin.

Prototype

public BytesRef getMin() throws IOException 

Source Link

Document

Returns the smallest term (in lexicographic order) in the field.

Usage

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;// w w  w . j  a  v  a 2  s .com
    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.apache.solr.legacy.LegacyNumericUtils.java

License:Apache License

/**
 * Returns the minimum int value indexed into this
 * numeric field or null if no terms exist.
 *///from  w ww  .ja  v  a  2s  .  com
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;
}

From source file:org.apache.solr.legacy.LegacyNumericUtils.java

License:Apache License

/**
 * Returns the minimum long value indexed into this
 * numeric field or null if no terms exist.
 *//*w  w w.  jav  a  2 s .c o  m*/
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;
}

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//w  w  w.j av  a 2  s  . c o  m
 */
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.
 */// w ww . j  av a2 s  .  co  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());
}