Package org.elasticsearch.search.facet.terms

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


        srb.setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), geoFilter));
        return collectObjects(srb.execute().actionGet());
    }

    public Set<String> getQuerySuggestions(JetwickQuery query, SearchResponse rsp, long hits) {
        TermsFacet tags = (TermsFacet) rsp.facets().facet(ElasticTweetSearch.TAG);

        if (tags == null)
            return Collections.emptySet();
        Set<String> tmp = new LinkedHashSet<String>();
        for (TermsFacet.Entry e : tags.entries()) {
//            logger.info(e.term() + " " + e.count() + " " + hits);
            if (e.count() > hits / 10000.0 + 1) {
                boolean contains = false;
                for (String tmpTerm : tmp) {
                    if (e.term().contains(tmpTerm) || tmpTerm.contains(e.term()))
View Full Code Here


      // search All + facet country

      IndexQuery<Team> queryCountry = Team.find.query();
      queryCountry.addFacet(FacetBuilders.termsFacet("countryF").field("country.name"));
      IndexResults<Team> allAndFacetCountry = Team.find.search(queryCountry);
      TermsFacet countryF = allAndFacetCountry.facets.facet("countryF");

      // search All + facet players.position
      IndexQuery<Team> queryPlayers = Team.find.query();
      queryPlayers.addFacet(FacetBuilders.termsFacet("playersF").field("players.position").nested("players"));
      IndexResults<Team> allAndFacetAge = Team.find.search(queryPlayers);
View Full Code Here

            setQuery(QueryBuilders.matchAllQuery()).
            setSize(0).
            addFacet(facetBuilder).
            execute().actionGet();

        TermsFacet facetResult = searchResponse.facets().facet(TermsFacet.class, "tags");
        for (TermsFacet.Entry entry : facetResult.entries()) {
            tags.add(new Tag(entry.term(), entry.count()));
        }

        return tags;
    }
View Full Code Here

                .getBytes("UTF-8"))
          .execute().actionGet();

      assertThat(searchResponse.hits().totalHits(), equalTo(documentCount));

         TermsFacet facet = searchResponse.facets().facet("facet1");
      assertThat(facet.name(), equalTo("facet1"));
      assertThat(facet.entries().size(), equalTo(getFacetSize()));
      assertThat(facet.totalCount(),equalTo(fieldTokenCount));
      assertThat(facet.missingCount(),equalTo(1L)); // one missing doc.

      for (int term=maxTermCount()-getFacetSize()+1;term<=maxTermCount();term++) {
        int facet_pos = maxTermCount()-term;
       
        assertThat(facet.entries().get(facet_pos).term(),equalToIgnoringCase(getTerm(term)));
        assertThat(facet.entries().get(facet_pos).count(),equalTo(term));
      }
    }
  }
View Full Code Here

                .getBytes("UTF-8"))
          .execute().actionGet();

      assertThat(searchResponse.hits().totalHits(), equalTo(documentCount));

         TermsFacet facet = searchResponse.facets().facet("facet1");
      logFacet(facet);
      assertThat(facet.name(), equalTo("facet1"));
      assertThat(facet.entries().size(), equalTo(facet_size));
         assertThat(facet.totalCount(),equalTo(fieldTokenCount));
      assertThat(facet.missingCount(),equalTo(1L)); // one missing doc.

      for (int term=maxTermCount()-facet_size+1;term<=maxTermCount();term++) {
        int facet_pos = maxTermCount()-term;

            String termS = getTerm(term,true);
        assertThat(facet.entries().get(facet_pos).term(),equalTo(String.format("%s|%s",termS,
                    HashedStringFieldType.hashCode(termS))));
        assertThat(facet.entries().get(facet_pos).count(),equalTo(term));
      }
    }
  }
View Full Code Here

                .getBytes("UTF-8"))
          .execute().actionGet();

      assertThat(searchResponse.hits().totalHits(), equalTo(documentCount));

      TermsFacet facet = searchResponse.facets().facet("facet1");
      assertThat(facet.name(), equalTo("facet1"));
      assertThat(facet.entries().size(), equalTo(facet_size));
         assertThat(facet.totalCount(),equalTo(fieldTokenCount));
         assertThat(facet.missingCount(),equalTo(1L)); // one missing doc.
     
      int maxTermInFacet = maxTermCount()-2;

      for (int term=maxTermInFacet-facet_size+1;term<=maxTermInFacet-2;term++) {
        int facet_pos = maxTermInFacet-term;
       
        assertThat(facet.entries().get(facet_pos).term(),equalToIgnoringCase(getTerm(term)));
        assertThat(facet.entries().get(facet_pos).count(),equalTo(term));
      }
    }
  }
View Full Code Here

                                 .getBytes("UTF-8"))
                 .execute().actionGet();

         assertThat(searchResponse.hits().totalHits(), equalTo(documentCount));

         TermsFacet facet = searchResponse.facets().facet("facet1");
         assertThat(facet.name(), equalTo("facet1"));
         assertThat(facet.entries().size(), equalTo(2));
         assertThat(facet.totalCount(),equalTo(fieldTokenCount));
         assertThat(facet.missingCount(),equalTo(1L)); // one missing doc.

         assertThat(facet.entries().get(0).term(),equalToIgnoringCase(getTerm(maxTermCount())));
         assertThat(facet.entries().get(0).count(),equalTo(maxTermCount()));
         assertThat(facet.entries().get(1).term(),equalToIgnoringCase(getTerm(maxTermCount()-1)));
         assertThat(facet.entries().get(1).count(),equalTo(maxTermCount()-1));

      }
   }
View Full Code Here

                  .endObject().endObject().bytes()).execute()
          .actionGet();

      assertThat(searchResponse.hits().totalHits(), equalTo(2l));
      assertThat(searchResponse.hits().hits().length, equalTo(0));
      TermsFacet facet = searchResponse.facets().facet("facet1");
      assertThat(facet.name(), equalTo("facet1"));
      assertThat(facet.entries().size(), equalTo(2));
      assertThat(facet.entries().get(0).term(),
          anyOf(equalTo("green"), equalTo("blue")));
      assertThat(facet.entries().get(0).count(), equalTo(1));
      assertThat(facet.entries().get(1).term(),
          anyOf(equalTo("green"), equalTo("blue")));
      assertThat(facet.entries().get(1).count(), equalTo(1));
    }
  }
View Full Code Here

                               .endObject().endObject().bytes()).execute()
          .actionGet();

      assertThat(searchResponse.hits().totalHits(), equalTo(documentCount));
      assertThat(searchResponse.hits().hits().length, equalTo(0));
      TermsFacet facet = searchResponse.facets().facet("facet1");
      assertThat(facet.name(), equalTo("facet1"));
      assertThat(facet.entries().size(), equalTo(10 + i));
      assertThat(facet.entries().get(0).term(),equalTo("term_0"));
      assertThat(facet.entries().get(0).count(), equalTo(10+i));
      assertThat(facet.entries().get(1).term(),equalTo("term_1"));
      assertThat(facet.entries().get(1).count(), equalTo(9+i));
    }
   }
View Full Code Here

                  .endObject().endObject().bytes()).execute()
          .actionGet();

      assertThat(searchResponse.hits().totalHits(), equalTo(2l));
      assertThat(searchResponse.hits().hits().length, equalTo(0));
      TermsFacet facet = searchResponse.facets().facet("facet1");
     
      logFacet(facet);
     
      assertThat(facet.entries().size(), equalTo(4));
      assertThat(facet.entries().get(0).term(),equalTo("2"));
      assertThat(facet.entries().get(0).count(), equalTo(2));
     
      assertThat(facet.entries().get(1).term(),
          anyOf(equalTo("1"), equalTo("3"),equalTo("4")));
      assertThat(facet.entries().get(1).count(), equalTo(1));
     
      assertThat(facet.entries().get(2).term(),
          anyOf(equalTo("1"), equalTo("3"),equalTo("4")));
      assertThat(facet.entries().get(2).count(), equalTo(1));
     
      assertThat(facet.entries().get(3).term(),
          anyOf(equalTo("1"), equalTo("3"),equalTo("4")));
      assertThat(facet.entries().get(3).count(), equalTo(1));
    }
  }
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.