org.elasticsearch.search.facet.terms.TermsFacet Java Examples

The following examples show how to use org.elasticsearch.search.facet.terms.TermsFacet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticSearchResult.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public TermFrequency getTerms() throws IOException {
    if (facet == null) {
        return new ElasticSearchTermFrequency();
    }

    String[] terms = new String[facet.getEntries().size()];
    int[] frequencies = new int[facet.getEntries().size()];

    int i = 0;

    for (TermsFacet.Entry termFacet : facet.getEntries()) {
        terms[i] = termFacet.getTerm().string();
        frequencies[i] = termFacet.getCount();
        i++;
    }

    return new ElasticSearchTermFrequency(terms, frequencies);
}
 
Example #2
Source File: ElasticSearchResult.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public TermFrequency getTerms() throws IOException {
    if (facet == null) {
        return new ElasticSearchTermFrequency();
    }

    String[] terms = new String[facet.getEntries().size()];
    int[] frequencies = new int[facet.getEntries().size()];

    int i = 0;

    for (TermsFacet.Entry termFacet : facet.getEntries()) {
        terms[i] = termFacet.getTerm().string();
        frequencies[i] = termFacet.getCount();
        i++;
    }

    return new ElasticSearchTermFrequency(terms, frequencies);
}