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

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

源代码1 项目: Elasticsearch   文件: DateFieldMapper.java
@Override
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    long minValue = NumericUtils.getMinLong(terms);
    long maxValue = NumericUtils.getMaxLong(terms);
    return new FieldStats.Date(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), minValue, maxValue, dateTimeFormatter()
    );
}
 
源代码2 项目: Elasticsearch   文件: ShortFieldMapper.java
@Override
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    long minValue = NumericUtils.getMinInt(terms);
    long maxValue = NumericUtils.getMaxInt(terms);
    return new FieldStats.Long(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), minValue, maxValue
    );
}
 
源代码3 项目: Elasticsearch   文件: FloatFieldMapper.java
@Override
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    float minValue = NumericUtils.sortableIntToFloat(NumericUtils.getMinInt(terms));
    float maxValue = NumericUtils.sortableIntToFloat(NumericUtils.getMaxInt(terms));
    return new FieldStats.Float(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), minValue, maxValue
    );
}
 
源代码4 项目: Elasticsearch   文件: DoubleFieldMapper.java
@Override
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    double minValue = NumericUtils.sortableLongToDouble(NumericUtils.getMinLong(terms));
    double maxValue = NumericUtils.sortableLongToDouble(NumericUtils.getMaxLong(terms));
    return new FieldStats.Double(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), minValue, maxValue
    );
}
 
源代码5 项目: Elasticsearch   文件: IntegerFieldMapper.java
@Override
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    long minValue = NumericUtils.getMinInt(terms);
    long maxValue = NumericUtils.getMaxInt(terms);
    return new FieldStats.Long(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), minValue, maxValue
    );
}
 
源代码6 项目: Elasticsearch   文件: ByteFieldMapper.java
@Override
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    long minValue = NumericUtils.getMinInt(terms);
    long maxValue = NumericUtils.getMaxInt(terms);
    return new FieldStats.Long(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), minValue, maxValue
    );
}
 
源代码7 项目: Elasticsearch   文件: LongFieldMapper.java
@Override
public FieldStats stats(Terms terms, int maxDoc) throws IOException {
    long minValue = NumericUtils.getMinLong(terms);
    long maxValue = NumericUtils.getMaxLong(terms);
    return new FieldStats.Long(
        maxDoc, terms.getDocCount(), terms.getSumDocFreq(), terms.getSumTotalTermFreq(), minValue, maxValue
    );
}
 
/**
 * Returns the average number of unique terms times the number of docs belonging to the input class
 *
 * @param  term the class term
 * @return the average number of unique terms
 * @throws java.io.IOException If there is a low-level I/O error
 */
private double getTextTermFreqForClass(Term term, String fieldName) throws IOException {
  double avgNumberOfUniqueTerms;
  Terms terms = MultiTerms.getTerms(indexReader, fieldName);
  long numPostings = terms.getSumDocFreq(); // number of term/doc pairs
  avgNumberOfUniqueTerms = numPostings / (double) terms.getDocCount(); // avg # of unique terms per doc
  int docsWithC = indexReader.docFreq(term);
  return avgNumberOfUniqueTerms * docsWithC; // avg # of unique terms in text fields per doc * # docs with c
}
 
源代码9 项目: lucene-solr   文件: SimpleNaiveBayesClassifier.java
/**
 * Returns the average number of unique terms times the number of docs belonging to the input class
 * @param term the term representing the class
 * @return the average number of unique terms
 * @throws IOException if a low level I/O problem happens
 */
private double getTextTermFreqForClass(Term term) throws IOException {
  double avgNumberOfUniqueTerms = 0;
  for (String textFieldName : textFieldNames) {
    Terms terms = MultiTerms.getTerms(indexReader, textFieldName);
    long numPostings = terms.getSumDocFreq(); // number of term/doc pairs
    avgNumberOfUniqueTerms += numPostings / (double) terms.getDocCount(); // avg # of unique terms per doc
  }
  int docsWithC = indexReader.docFreq(term);
  return avgNumberOfUniqueTerms * docsWithC; // avg # of unique terms in text fields per doc * # docs with c
}
 
源代码10 项目: 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()
    );
}
 
源代码11 项目: lucene-solr   文件: DocIdSetBuilder.java
/** Create a {@link DocIdSetBuilder} instance that is optimized for
 *  accumulating docs that match the given {@link Terms}. */
public DocIdSetBuilder(int maxDoc, Terms terms) throws IOException {
  this(maxDoc, terms.getDocCount(), terms.getSumDocFreq());
}