Search in sources :

Example 1 with StringStatsAggregate

use of org.opensearch.client.opensearch._types.aggregations.StringStatsAggregate in project opensearch-java by opensearch-project.

the class BuiltinTypesTest method testNullableInt.

@Test
public void testNullableInt() {
    StringStatsAggregate stats = StringStatsAggregate.of(b -> b.count(1).minLength(2).avgLength(3).maxLength(4).entropy(0));
    stats = checkJsonRoundtrip(stats, "{\"count\":1,\"min_length\":2,\"max_length\":4,\"avg_length\":3.0,\"entropy\":0.0}");
    assertEquals(2, stats.minLength());
    assertEquals(4, stats.maxLength());
    // Missing values
    String json = "{\"count\":1,\"min_length\":null,\"max_length\":null,\"avg_length\":null,\"entropy\":null}";
    stats = fromJson(json, StringStatsAggregate.class);
    assertEquals(0, stats.minLength());
    assertEquals(0, stats.maxLength());
    assertEquals(0.0, stats.entropy(), 0.01);
}
Also used : StringStatsAggregate(org.opensearch.client.opensearch._types.aggregations.StringStatsAggregate) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 StringStatsAggregate (org.opensearch.client.opensearch._types.aggregations.StringStatsAggregate)1