Search in sources :

Example 1 with NumericRangeBucket

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

the class AggregationMapper method serializeBucket.

private static void serializeBucket(final MapGenerator gen, final Bucket value) {
    gen.map();
    gen.value("key", value.getKey());
    gen.value("docCount", value.getDocCount());
    if (value instanceof DateRangeBucket) {
        serializeDateBucket(gen, (DateRangeBucket) value);
    } else if (value instanceof NumericRangeBucket) {
        serializeNumericBucket(gen, (NumericRangeBucket) value);
    }
    final Aggregations subAggregations = value.getSubAggregations();
    if (subAggregations != null) {
        serializeAggregations(gen, subAggregations);
    }
    gen.end();
}
Also used : Aggregations(com.enonic.xp.aggregation.Aggregations) DateRangeBucket(com.enonic.xp.aggregation.DateRangeBucket) NumericRangeBucket(com.enonic.xp.aggregation.NumericRangeBucket)

Example 2 with NumericRangeBucket

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

the class AggregationMapper method serializeBucket.

private static void serializeBucket(final MapGenerator gen, final Bucket value) {
    gen.map();
    gen.value("key", value.getKey());
    gen.value("docCount", value.getDocCount());
    if (value instanceof DateRangeBucket) {
        serializeDateBucket(gen, (DateRangeBucket) value);
    } else if (value instanceof NumericRangeBucket) {
        serializeNumericBucket(gen, (NumericRangeBucket) value);
    }
    final Aggregations subAggregations = value.getSubAggregations();
    if (subAggregations != null) {
        serializeAggregations(gen, subAggregations);
    }
    gen.end();
}
Also used : Aggregations(com.enonic.xp.aggregation.Aggregations) DateRangeBucket(com.enonic.xp.aggregation.DateRangeBucket) NumericRangeBucket(com.enonic.xp.aggregation.NumericRangeBucket)

Example 3 with NumericRangeBucket

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

the class NumericRangeAggregationTest method verifyBucket.

private void verifyBucket(final Bucket bucket, final int count, final String key) {
    assertTrue(bucket instanceof NumericRangeBucket);
    final NumericRangeBucket buck = (NumericRangeBucket) bucket;
    assertEquals(count, buck.getDocCount());
    if (!isNullOrEmpty(key)) {
        assertEquals(buck.getKey(), key);
    }
}
Also used : NumericRangeBucket(com.enonic.xp.aggregation.NumericRangeBucket)

Aggregations

NumericRangeBucket (com.enonic.xp.aggregation.NumericRangeBucket)3 Aggregations (com.enonic.xp.aggregation.Aggregations)2 DateRangeBucket (com.enonic.xp.aggregation.DateRangeBucket)2