Examples of FieldStatsResult


Examples of org.graylog2.indexer.results.FieldStatsResult

            r = c.search(request).actionGet();
        } catch (org.elasticsearch.action.search.SearchPhaseExecutionException e) {
            throw new FieldTypeException(e);
        }

        return new FieldStatsResult(
                (StatisticalFacet) r.getFacets().facet(STATS_FACET_NAME),
                r.getHits(),
                query,
                request.source(),
                r.getTook()
View Full Code Here

Examples of org.graylog2.indexer.results.FieldStatsResult

    @Override
    protected CheckResult runCheck() {
        this.searchHits = Collections.emptyList();
        try {
            String filter = "streams:" + stream.getId();
            FieldStatsResult fieldStatsResult = searches.fieldStats(field, "*", filter, new RelativeRange(time * 60));
            if (getBacklog() != null && getBacklog() > 0) {
                this.searchHits = Lists.newArrayList();
                for (ResultMessage resultMessage : fieldStatsResult.getSearchHits()) {
                    this.searchHits.add(new Message(resultMessage.getMessage()));
                }
            }

            if (fieldStatsResult.getCount() == 0) {
                LOG.debug("Alert check <{}> did not match any messages. Returning not triggered.", type);
                return new CheckResult(false);
            }

            double result;
            switch (type) {
                case MEAN:
                    result = fieldStatsResult.getMean();
                    break;
                case MIN:
                    result = fieldStatsResult.getMin();
                    break;
                case MAX:
                    result = fieldStatsResult.getMax();
                    break;
                case SUM:
                    result = fieldStatsResult.getSum();
                    break;
                case STDDEV:
                    result = fieldStatsResult.getStdDeviation();
                    break;
                default:
                    LOG.error("No such field value check type: [{}]. Returning not triggered.", type);
                    return new CheckResult(false);
            }
View Full Code Here

Examples of org.graylog2.indexer.results.FieldStatsResult

        }
    }

    protected FieldStatsResult getFieldStatsResult(FieldValueAlertCondition.CheckType type, Number retValue) {
        final Double value = (Double)retValue;
        final FieldStatsResult fieldStatsResult = mock(FieldStatsResult.class);

        when(fieldStatsResult.getCount()).thenReturn(1L);

        switch (type) {
            case MIN:
                when(fieldStatsResult.getMin()).thenReturn(value);
            case MAX:
                when(fieldStatsResult.getMax()).thenReturn(value);
            case MEAN:
                when(fieldStatsResult.getMean()).thenReturn(value);
            case STDDEV:
                when(fieldStatsResult.getStdDeviation()).thenReturn(value);
            case SUM:
                when(fieldStatsResult.getSum()).thenReturn(value);
        }
        return fieldStatsResult;
    }
View Full Code Here

Examples of org.springframework.data.solr.core.query.result.FieldStatsResult

    SimpleQuery statsQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));
    statsQuery.setStatsOptions(statsOptions);
    StatsPage<ExampleSolrBean> statResultPage = solrTemplate.queryForStatsPage(statsQuery, ExampleSolrBean.class);

    FieldStatsResult priceStatResult = statResultPage.getFieldStatsResult("price");
    FieldStatsResult popularityStatResult = statResultPage.getFieldStatsResult("popularity");

    Assert.assertEquals(Long.valueOf(2), priceStatResult.getDistinctCount());
    Collection<Object> distinctValues = priceStatResult.getDistinctValues();
    Assert.assertEquals(2, distinctValues.size());
    Assert.assertTrue(distinctValues.contains(10.0F));
    Assert.assertTrue(distinctValues.contains(20.0F));
    Assert.assertEquals(null, popularityStatResult.getDistinctCount());
  }
View Full Code Here

Examples of org.springframework.data.solr.core.query.result.FieldStatsResult

    SimpleQuery statsQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));
    statsQuery.setStatsOptions(statsOptions);
    StatsPage<ExampleSolrBean> statResultPage = solrTemplate.queryForStatsPage(statsQuery, ExampleSolrBean.class);

    FieldStatsResult priceStats = statResultPage.getFieldStatsResult("price");
    Assert.assertEquals(Long.valueOf(2), priceStats.getCount());
    Assert.assertEquals(10D, priceStats.getMin());
    Assert.assertEquals(20.50, priceStats.getMax());
    Assert.assertEquals(Double.valueOf(10), priceStats.getMinAsDouble());
    Assert.assertEquals(Double.valueOf(20.50), priceStats.getMaxAsDouble());
    Assert.assertEquals("10.0", priceStats.getMinAsString());
    Assert.assertEquals("20.5", priceStats.getMaxAsString());
    Assert.assertNull(priceStats.getMinAsDate());
    Assert.assertNull(priceStats.getMaxAsDate());
    Assert.assertEquals(Double.valueOf(15.25), priceStats.getMean());
    Assert.assertEquals(Double.valueOf(30.50), priceStats.getSum());
    Assert.assertEquals(Long.valueOf(0), priceStats.getMissing());
    Assert.assertEquals(Double.valueOf(7.424621202458749), priceStats.getStddev());
    Assert.assertEquals(Double.valueOf(520.25), priceStats.getSumOfSquares());

    Map<String, StatsResult> facetStatsResult = priceStats.getFacetStatsResult(new SimpleField("name"));
    Assert.assertEquals(2, facetStatsResult.size());
    {
      StatsResult nameFacetStatsResult = facetStatsResult.get("one");
      Assert.assertEquals(Long.valueOf(1), nameFacetStatsResult.getCount());
      Assert.assertEquals(10D, nameFacetStatsResult.getMin());
View Full Code Here

Examples of org.springframework.data.solr.core.query.result.FieldStatsResult

    repo.save(created);

    StatsPage<ProductBean> statsPage = repo.findAllWithStats(new SolrPageRequest(0, 0));

    FieldStatsResult id = statsPage.getFieldStatsResult("id");
    FieldStatsResult price = statsPage.getFieldStatsResult("price");
    FieldStatsResult weight = statsPage.getFieldStatsResult("weight");

    Assert.assertNotNull(id);
    Assert.assertNotNull(price);
    Assert.assertNotNull(price.getFacetStatsResult("id"));
    Assert.assertNotNull(price.getFacetStatsResult("last_modified"));
    Assert.assertNull(price.getFacetStatsResult("inStock"));
    Assert.assertNotNull(id.getFacetStatsResult("id"));
    Assert.assertNotNull(id.getFacetStatsResult("last_modified"));
    Assert.assertNull(id.getFacetStatsResult("inStock"));

    Assert.assertNotNull(weight);
    Assert.assertNotNull(weight.getFacetStatsResult("inStock"));
    Assert.assertNull(weight.getFacetStatsResult("last_modified"));
    Assert.assertNull(weight.getFacetStatsResult("id"));
  }
View Full Code Here

Examples of org.springframework.data.solr.core.query.result.FieldStatsResult

    fieldStatsInfos.put("field", new FieldStatsInfo(nl, "field"));

    Map<String, FieldStatsResult> converted = ResultHelper.convertFieldStatsInfoToFieldStatsResultMap(fieldStatsInfos);

    FieldStatsResult fieldStatsResult = converted.get("field");

    Assert.assertEquals("min", fieldStatsResult.getMin());
    Assert.assertEquals("max", fieldStatsResult.getMax());
    Assert.assertEquals(Double.valueOf(20), fieldStatsResult.getSum());
    Assert.assertEquals(Double.valueOf(22.5), fieldStatsResult.getMean());
    Assert.assertEquals(Long.valueOf(10), fieldStatsResult.getCount());
    Assert.assertEquals(Long.valueOf(5), fieldStatsResult.getMissing());
    Assert.assertEquals(Double.valueOf(15.5), fieldStatsResult.getStddev());
    Assert.assertEquals(Double.valueOf(1D), fieldStatsResult.getSumOfSquares());
  }
View Full Code Here

Examples of org.springframework.data.solr.core.query.result.FieldStatsResult

    // convert
    Map<String, FieldStatsResult> converted = ResultHelper.convertFieldStatsInfoToFieldStatsResultMap(fieldStatsInfos);

    // field
    FieldStatsResult fieldStatsResult = converted.get("field");
    Assert.assertEquals("min", fieldStatsResult.getMin());
    Assert.assertEquals("max", fieldStatsResult.getMax());
    Assert.assertEquals(Double.valueOf(20), fieldStatsResult.getSum());
    Assert.assertEquals(Double.valueOf(22.5), fieldStatsResult.getMean());
    Assert.assertEquals(Long.valueOf(10), fieldStatsResult.getCount());
    Assert.assertEquals(Long.valueOf(5), fieldStatsResult.getMissing());
    Assert.assertEquals(Double.valueOf(15.5), fieldStatsResult.getStddev());

    // facets
    Map<String, Map<String, StatsResult>> facetStatsResults = fieldStatsResult.getFacetStatsResults();
    Assert.assertEquals(1, facetStatsResults.size());

    // facet field
    Map<String, StatsResult> facetStatsResult = facetStatsResults.get("facetField");
    Assert.assertNotNull(facetStatsResult);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.