Search in sources :

Example 1 with SingleValueMetricAggregation

use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.

the class QueryContentHandlerTest method testMinAggregation.

@Test
public void testMinAggregation() {
    final SingleValueMetricAggregation minAgg = SingleValueMetricAggregation.create("minPrice").value(10.0).build();
    setUpForMetricsAggregations(minAgg);
    runFunction("/test/QueryContentHandlerTest_MinAggregation.js", "queryWithAggregations");
}
Also used : SingleValueMetricAggregation(com.enonic.xp.aggregation.SingleValueMetricAggregation) Test(org.junit.jupiter.api.Test)

Example 2 with SingleValueMetricAggregation

use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.

the class ValueCountAggregationTest method verifyValueCount.

private void verifyValueCount(final Bucket parentBucket, String parentBucketKey, double value) {
    assertEquals(parentBucketKey, parentBucket.getKey(), "Wrong parent bucket key");
    assertEquals(1, parentBucket.getSubAggregations().getSize());
    final Aggregation subAgg = parentBucket.getSubAggregations().get("subquery");
    assertTrue(subAgg instanceof SingleValueMetricAggregation);
    final SingleValueMetricAggregation stats = (SingleValueMetricAggregation) subAgg;
    assertEquals(value, stats.getValue(), 0);
}
Also used : BucketAggregation(com.enonic.xp.aggregation.BucketAggregation) SingleValueMetricAggregation(com.enonic.xp.aggregation.SingleValueMetricAggregation) Aggregation(com.enonic.xp.aggregation.Aggregation) SingleValueMetricAggregation(com.enonic.xp.aggregation.SingleValueMetricAggregation)

Example 3 with SingleValueMetricAggregation

use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.

the class AggregationMapper method serializeAggregations.

private static void serializeAggregations(final MapGenerator gen, final Aggregations value) {
    for (Aggregation aggregation : value) {
        gen.map(aggregation.getName());
        if (aggregation instanceof BucketAggregation) {
            final Buckets buckets = ((BucketAggregation) aggregation).getBuckets();
            serializeBuckets(gen, buckets);
        } else if (aggregation instanceof StatsAggregation) {
            final StatsAggregation statsAggregation = ((StatsAggregation) aggregation);
            serializeStatsAggregation(gen, statsAggregation);
        } else if (aggregation instanceof SingleValueMetricAggregation) {
            gen.value("value", ((SingleValueMetricAggregation) aggregation).getValue());
        }
        gen.end();
    }
}
Also used : BucketAggregation(com.enonic.xp.aggregation.BucketAggregation) Aggregation(com.enonic.xp.aggregation.Aggregation) SingleValueMetricAggregation(com.enonic.xp.aggregation.SingleValueMetricAggregation) StatsAggregation(com.enonic.xp.aggregation.StatsAggregation) SingleValueMetricAggregation(com.enonic.xp.aggregation.SingleValueMetricAggregation) StatsAggregation(com.enonic.xp.aggregation.StatsAggregation) BucketAggregation(com.enonic.xp.aggregation.BucketAggregation) Buckets(com.enonic.xp.aggregation.Buckets)

Example 4 with SingleValueMetricAggregation

use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.

the class QueryContentHandlerTest method testMaxAggregation.

@Test
public void testMaxAggregation() {
    final SingleValueMetricAggregation maxAgg = SingleValueMetricAggregation.create("maxPrice").value(50.0).build();
    setUpForMetricsAggregations(maxAgg);
    runFunction("/test/QueryContentHandlerTest_MaxAggregation.js", "queryWithAggregations");
}
Also used : SingleValueMetricAggregation(com.enonic.xp.aggregation.SingleValueMetricAggregation) Test(org.junit.jupiter.api.Test)

Example 5 with SingleValueMetricAggregation

use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.

the class QueryContentHandlerTest method testValueCountAggregation.

@Test
public void testValueCountAggregation() {
    final SingleValueMetricAggregation countAgg = SingleValueMetricAggregation.create("countProductsWithPrice").value(5).build();
    setUpForMetricsAggregations(countAgg);
    runFunction("/test/QueryContentHandlerTest_ValueCountAggregation.js", "queryWithAggregations");
}
Also used : SingleValueMetricAggregation(com.enonic.xp.aggregation.SingleValueMetricAggregation) Test(org.junit.jupiter.api.Test)

Aggregations

SingleValueMetricAggregation (com.enonic.xp.aggregation.SingleValueMetricAggregation)5 Test (org.junit.jupiter.api.Test)3 Aggregation (com.enonic.xp.aggregation.Aggregation)2 BucketAggregation (com.enonic.xp.aggregation.BucketAggregation)2 Buckets (com.enonic.xp.aggregation.Buckets)1 StatsAggregation (com.enonic.xp.aggregation.StatsAggregation)1