Package org.elasticsearch.search.facet.terms

Examples of org.elasticsearch.search.facet.terms.TermsFacet$Entry


    Assert.assertNotNull(sr.getFacets());
    Assert.assertNotNull(sr.getFacets().facet("bybrand"));
    Assert.assertEquals("terms", sr.getFacets().facet("bybrand").getType());

    TermsFacet bybrand = sr.getFacets().facet("bybrand");
   
    int nbHeineken = 0;
    int nbGrimbergen = 0;
    int nbKriek = 0;
   
View Full Code Here


    Assert.assertNotNull(sr.getFacets());
    Assert.assertNotNull(sr.getFacets().facet("bybrand"));
    Assert.assertEquals("terms", sr.getFacets().facet("bybrand").getType());

    TermsFacet bybrand = sr.getFacets().facet("bybrand");
   
    int nbHeineken = 0;
    int nbGrimbergen = 0;
    int nbKriek = 0;
   
View Full Code Here

        if (facets == null)
            return ret;

        for (Facet facet : facets.facets()) {
            if (facet instanceof TermsFacet) {
                TermsFacet ff = (TermsFacet) facet;
                Integer integ = filterToIndex.get(ff.getName());
                if (integ != null && ff.entries() != null) {
                    List<FacetHelper> list = new ArrayList<FacetHelper>();
                    String key = ff.getName();
                    for (TermsFacet.Entry e : ff.entries()) {
                        String term = e.getTerm();
                        if ("T".equals(term))
                            term = "true";
                        else if ("F".equals(term))
                            term = "false";

                        // exclude smaller zero?
                        list.add(new FacetHelper(key, term,
                                translate(key + ":" + term), e.getCount()));
                    }
                    ret.set(integ, new MapEntry(ff.getName(), list));
                }
            } else if (facet instanceof FilterFacet) {
                FilterFacet ff = (FilterFacet) facet;
                String name = ff.getName();
                int firstIndex = name.indexOf(":");
                if (firstIndex < 0)
                    continue;

                String key = name.substring(0, firstIndex);
                if (DATE.equals(key))
                    continue;

                String val = name.substring(firstIndex + 1);

                // exclude smaller zero?
                Long count = ff.count();
                if (count == null)
                    count = 0L;

                Integer index = filterToIndex.get(key);
                if (index == null)
View Full Code Here

        Set<String> terms = new HashSet<String>();
        if (query.getQuery() != null)
            terms.addAll(Arrays.asList(query.getQuery().split(" ")));

        if (rsp != null && rsp.facets() != null) {
            TermsFacet tf = (TermsFacet) rsp.facets().facet(ElasticTweetSearch.TAG);
            if (tf != null) {
                max = 0;
                Map<String, Long> tmp = new TreeMap<String, Long>();
                for (TermsFacet.Entry e : tf.entries()) {
                    if (terms.contains(e.getTerm()))
                        continue;

                    if (e.getCount() > max)
                        max = e.getCount();
View Full Code Here

        JetwickQuery query = new TweetQuery().addFilterQuery(ElasticTweetSearch.UPDATE_DT, "[* TO *]");
        // TODO set facetlimit to 2000
        query.addFacetField("user").setSize(0);
        SearchResponse rsp = fromUserSearch.query(query);

        TermsFacet tf = (TermsFacet) rsp.getFacets().facet("user");
        logger.info("found: " + tf.entries().size() + " users with the specified criteria");
        int SLEEP = 30;
        int counter = 0;
        for (TermsFacet.Entry tmpUser : tf.entries()) {
            if (tmpUser.getCount() < 20)
                break;

            while (twSearch.getRateLimit() <= 3) {
                try {
View Full Code Here

        srb.addFacet(FacetBuilders.termsFacet(QUERY_TERMS).field(QUERY_TERMS).size(1000)).
                setQuery(fb);
        SearchResponse rsp = srb.execute().actionGet();
//        SearchResponse rsp = search(new UserQuery().addFacetField(QUERY_TERMS, 1000));
        TermsFacet tf = (TermsFacet) rsp.getFacets().facet(QUERY_TERMS);
        if (tf.entries() != null && !tf.entries().isEmpty()) {
            Collection<String> res = new ArrayList<String>();
            for (TermsFacet.Entry cnt : tf.entries()) {
                if (cnt.getCount() > 0)
                    res.add(cnt.getTerm());
            }
            return res;
        }
View Full Code Here

                if (e.getKey().equals(ElasticTweetSearch.FIRST_URL_TITLE))
                    filter.set(0, true);
            }

            if (rsp.facets() != null) {
                TermsFacet tf = (TermsFacet) rsp.facets().facet(ElasticTweetSearch.FIRST_URL_TITLE);
                if (tf != null)
                    for (TermsFacet.Entry e : tf.entries()) {
                        String str = e.getTerm();
                        // although we avoid indexing empty title -> its save to do it again ;-)
                        if (!str.isEmpty())
                            urls.add(new MapEntry<String, Long>(str, (long) e.count()));
                    }
View Full Code Here

            @Override
            public List<Facet> facets() {
                Set<InternalStringTermsFacet.StringEntry> entries = new LinkedHashSet();
                entries.add(new InternalStringTermsFacet.StringEntry("de", 3));
                entries.add(new InternalStringTermsFacet.StringEntry("en", 2));
                TermsFacet tf = new InternalStringTermsFacet("lang", null, 1, entries, 0, 0);               
                Set<InternalStringTermsFacet.StringEntry> entries2 = new LinkedHashSet();
                entries2.add(new InternalStringTermsFacet.StringEntry("peter", 3));
                entries2.add(new InternalStringTermsFacet.StringEntry("karsten", 2));
                TermsFacet tf2 = new InternalStringTermsFacet("user", null, 1, entries2, 0, 0);               
                List<Facet> res = new ArrayList<Facet>();
                res.add(tf);
                res.add(tf2);
                return res;
            }
View Full Code Here

                tfb.regex(secPart + ".*", Pattern.DOTALL);

            srb.addFacet(tfb);
            SearchResponse rsp = query(new ArrayList<JUser>(), srb.execute().actionGet());
            Set<String> res = new TreeSet<String>();
            TermsFacet tf = rsp.facets().facet(TAG);
            if (tf != null) {
                for (TermsFacet.Entry cnt : tf.entries()) {
                    String lowerSugg = cnt.getTerm().toLowerCase();
                    if (existingTerms.contains(lowerSugg))
                        continue;

                    if (lowerSugg.startsWith(secPart)) {
View Full Code Here

                return Collections.emptyList();

            Set<String> set = new LinkedHashSet<String>();
            for (Facet facet : facets.facets()) {
                if (facet instanceof TermsFacet) {
                    TermsFacet ff = (TermsFacet) facet;
                    for (TermsFacet.Entry e : ff.entries()) {
                        if (e.count() > limit)
                            set.add(e.getTerm());
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.facet.terms.TermsFacet$Entry

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.