Package org.elasticsearch.search.facet.datehistogram

Examples of org.elasticsearch.search.facet.datehistogram.DateHistogramFacet


                    logger.warn("-> {}", shardSearchFailure);
                }
            }
            assertThat(searchResponse.failedShards(), equalTo(0));

            DateHistogramFacet facet = searchResponse.facets().facet("stats1");
            assertThat(facet.name(), equalTo("stats1"));
            assertThat(facet.entries().size(), equalTo(2));
            assertThat(facet.entries().get(0).time(), equalTo(utcTimeInMillis("2009-03-05")));
            assertThat(facet.entries().get(0).count(), equalTo(2l));
            assertThat(facet.entries().get(1).time(), equalTo(utcTimeInMillis("2009-03-06")));
            assertThat(facet.entries().get(1).count(), equalTo(1l));

            // time zone causes the dates to shift by 2
            facet = searchResponse.facets().facet("stats2");
            assertThat(facet.name(), equalTo("stats2"));
            assertThat(facet.entries().size(), equalTo(2));
            assertThat(facet.entries().get(0).time(), equalTo(timeInMillis("2009-03-04", DateTimeZone.forOffsetHours(-2))));
            assertThat(facet.entries().get(0).count(), equalTo(1l));
            assertThat(facet.entries().get(1).time(), equalTo(timeInMillis("2009-03-05", DateTimeZone.forOffsetHours(-2))));
            assertThat(facet.entries().get(1).count(), equalTo(2l));

            // time zone causes the dates to shift by 2
            facet = searchResponse.facets().facet("stats3");
            assertThat(facet.name(), equalTo("stats3"));
            assertThat(facet.entries().size(), equalTo(2));
            assertThat(facet.entries().get(0).time(), equalTo(timeInMillis("2009-03-04", DateTimeZone.forOffsetHours(-2))));
            assertThat(facet.entries().get(0).count(), equalTo(1l));
            assertThat(facet.entries().get(0).total(), equalTo(1d));
            assertThat(facet.entries().get(1).time(), equalTo(timeInMillis("2009-03-05", DateTimeZone.forOffsetHours(-2))));
            assertThat(facet.entries().get(1).count(), equalTo(2l));
            assertThat(facet.entries().get(1).total(), equalTo(5d));

            // time zone causes the dates to shift by 2
            facet = searchResponse.facets().facet("stats4");
            assertThat(facet.name(), equalTo("stats4"));
            assertThat(facet.entries().size(), equalTo(2));
            assertThat(facet.entries().get(0).time(), equalTo(timeInMillis("2009-03-04", DateTimeZone.forOffsetHours(-2))));
            assertThat(facet.entries().get(0).count(), equalTo(1l));
            assertThat(facet.entries().get(0).total(), equalTo(2d));
            assertThat(facet.entries().get(1).time(), equalTo(timeInMillis("2009-03-05", DateTimeZone.forOffsetHours(-2))));
            assertThat(facet.entries().get(1).count(), equalTo(2l));
            assertThat(facet.entries().get(1).total(), equalTo(10d));

            facet = searchResponse.facets().facet("stats5");
            assertThat(facet.name(), equalTo("stats5"));
            assertThat(facet.entries().size(), equalTo(2));
            assertThat(facet.entries().get(0).time(), equalTo(utcTimeInMillis("2009-03-05")));
            assertThat(facet.entries().get(0).count(), equalTo(2l));
            assertThat(facet.entries().get(1).time(), equalTo(utcTimeInMillis("2009-03-06")));
            assertThat(facet.entries().get(1).count(), equalTo(1l));
        }
    }
View Full Code Here


          }
        }
        rp.setGeo(geoCounts, nHighestCount, nLowestCount);
      }//(TESTED)
      if (facet.getKey().equals("time")) {
        DateHistogramFacet timeFacet = (DateHistogramFacet)facet.getValue();
        rp.setTimes(timeFacet.getEntries(), QueryHandler.getInterval(aggOutParams.timesInterval, 'm'));
      }//(TESTED)
     
      if (facet.getKey().equals("events")) {
        TermsFacet eventsFacet = (TermsFacet)facet.getValue();
        rp.setEvents(parseEventAggregationOutput("Event", eventsFacet, scoreStats, aliasLookup, entityTypeFilterStrings, assocVerbFilterStrings));
      }         
      if (facet.getKey().equals("facts")) {
        TermsFacet factsFacet = (TermsFacet)facet.getValue();
        rp.setFacts(parseEventAggregationOutput("Fact", factsFacet, scoreStats, aliasLookup, entityTypeFilterStrings, assocVerbFilterStrings));
      }         
      //TESTED x2
     
      if (facet.getKey().equals("sourceTags")) {
        TermsFacet tagsFacet = (TermsFacet)facet.getValue();
        rp.setSourceMetaTags(tagsFacet.getEntries());
      }
      if (facet.getKey().equals("sourceTypes")) {
        TermsFacet typesFacet = (TermsFacet)facet.getValue();
        rp.setSourceMetaTypes(typesFacet.getEntries());
      }
      if (facet.getKey().equals("sourceKeys")) {
        TermsFacet keysFacet = (TermsFacet)facet.getValue();
        rp.setSources(keysFacet.getEntries());
      }
      //TESTED x3
     
      // Moments (basic functionality)
     
      if (facet.getKey().startsWith("moments.")) {
        DateHistogramFacet momentFacet = (DateHistogramFacet) facet.getValue();
        if (null == moments) {
          moments = new HashMap<String, List<? extends Entry>>();
        }
        moments.put(facet.getKey().substring(8), momentFacet.getEntries());
      }//TESTED
       
    }//(end loop over generated facets) 
   
    if ((null != moments) && !moments.isEmpty()) {
View Full Code Here

            else if (requestedReport.equalsIgnoreCase("fileDownloads"))
            {
                SearchRequestBuilder requestBuilder = esStatsViewer.facetedQueryBuilder(esStatsViewer.facetMonthlyDownloads);
                SearchResponse searchResponse = requestBuilder.execute().actionGet();

                DateHistogramFacet monthlyDownloadsFacet = searchResponse.getFacets().facet(DateHistogramFacet.class, "monthly_downloads");
                addDateHistogramFacetToWriter(monthlyDownloadsFacet);
            }
            else if(requestedReport.equalsIgnoreCase("topDownloads"))
            {
                SearchRequestBuilder requestBuilder = esStatsViewer.facetedQueryBuilder(esStatsViewer.facetTopBitstreamsAllTime);
View Full Code Here

    public void dateHistogramFacet() throws Exception {
        DateHistogramFacetBuilder facet = FacetBuilders.dateHistogramFacet("f")
                .field("date")
                .interval("year");

        DateHistogramFacet f = (DateHistogramFacet) launchSearch(facet, "f");

        // For each entry
        for (DateHistogramFacet.Entry entry : f) {
            entry.getTime();    // Date in ms since epoch (X-Axis)
            entry.getCount();   // Doc count (Y-Axis)
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.facet.datehistogram.DateHistogramFacet

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.