Package org.xbib.elasticsearch.skywalker.stats

Examples of org.xbib.elasticsearch.skywalker.stats.TermStatsQueue


    }

    private static final TermStats[] EMPTY_STATS = new TermStats[0];

    public TermStats[] getHighFreqTerms(int numTerms, String[] fieldNames) {
        TermStatsQueue tiq = new TermStatsQueue(numTerms);
        TermsEnum te = null;
        try {
            if (fieldNames != null) {
                Fields fields = MultiFields.getFields(reader);
                if (fields == null) {
                    return EMPTY_STATS;
                }
                for (String field : fieldNames) {
                    Terms terms = fields.terms(field);
                    if (terms != null) {
                        te = terms.iterator(te);
                        fillQueue(te, tiq, field);
                    }
                }
            } else {
                Fields fields = MultiFields.getFields(reader);
                if (fields == null) {
                    return EMPTY_STATS;
                }
                for (String field : fields) {
                    Terms terms = fields.terms(field);
                    te = terms.iterator(te);
                    fillQueue(te, tiq, field);
                }
            }
        } catch (IOException e) {
            // ignore
        }
        TermStats[] result = new TermStats[tiq.size()];
        // we want highest first so we read the queue and populate the array
        // starting at the end and work backwards
        int count = tiq.size() - 1;
        while (tiq.size() != 0) {
            result[count] = tiq.pop();
            count--;
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.xbib.elasticsearch.skywalker.stats.TermStatsQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.