Package org.springframework.data.solr.core.query.result

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


    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

    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

    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

    // 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

Related Classes of org.springframework.data.solr.core.query.result.FieldStatsResult

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.