Search in sources :

Example 1 with PipelineAggregationBuilder

use of org.opensearch.search.aggregations.PipelineAggregationBuilder in project OpenSearch by opensearch-project.

the class SerialDifferenceTests method testInvalidParent.

public void testInvalidParent() throws IOException {
    final Set<PipelineAggregationBuilder> aggBuilders = new HashSet<>();
    aggBuilders.add(createTestAggregatorFactory());
    AggregationBuilder parent = mock(AggregationBuilder.class);
    when(parent.getName()).thenReturn("name");
    assertThat(validate(parent, new SerialDiffPipelineAggregationBuilder("name", "invalid_agg>metric")), equalTo("Validation Failed: 1: serial_diff aggregation [name] must have a histogram, " + "date_histogram or auto_date_histogram as parent;"));
}
Also used : AggregationBuilder(org.opensearch.search.aggregations.AggregationBuilder) PipelineAggregationBuilder(org.opensearch.search.aggregations.PipelineAggregationBuilder) PipelineAggregationBuilder(org.opensearch.search.aggregations.PipelineAggregationBuilder) HashSet(java.util.HashSet)

Example 2 with PipelineAggregationBuilder

use of org.opensearch.search.aggregations.PipelineAggregationBuilder in project OpenSearch by opensearch-project.

the class DerivativeTests method testValidateException.

/**
 * The validation should throw an IllegalArgumentException, since parent
 * aggregation is not a type of HistogramAggregatorFactory,
 * DateHistogramAggregatorFactory or AutoDateHistogramAggregatorFactory.
 */
public void testValidateException() throws IOException {
    final Set<PipelineAggregationBuilder> aggBuilders = new HashSet<>();
    aggBuilders.add(new DerivativePipelineAggregationBuilder("deriv", "der"));
    AggregationBuilder parent = mock(AggregationBuilder.class);
    when(parent.getName()).thenReturn("name");
    assertThat(validate(parent, new DerivativePipelineAggregationBuilder("name", "invalid_agg>metric")), equalTo("Validation Failed: 1: derivative aggregation [name] must have a histogram, " + "date_histogram or auto_date_histogram as parent;"));
}
Also used : AggregationBuilder(org.opensearch.search.aggregations.AggregationBuilder) PipelineAggregationBuilder(org.opensearch.search.aggregations.PipelineAggregationBuilder) PipelineAggregationBuilder(org.opensearch.search.aggregations.PipelineAggregationBuilder) HashSet(java.util.HashSet)

Example 3 with PipelineAggregationBuilder

use of org.opensearch.search.aggregations.PipelineAggregationBuilder in project OpenSearch by opensearch-project.

the class MovAvgTests method testDefaultParsing.

public void testDefaultParsing() throws Exception {
    MovAvgPipelineAggregationBuilder expected = new MovAvgPipelineAggregationBuilder("commits_moving_avg", "commits");
    String json = "{" + "    \"commits_moving_avg\": {" + "        \"moving_avg\": {" + "            \"buckets_path\": \"commits\"" + "        }" + "    }" + "}";
    PipelineAggregationBuilder newAgg = parse(createParser(JsonXContent.jsonXContent, json));
    assertWarnings("The moving_avg aggregation has been deprecated in favor of the moving_fn aggregation.");
    assertNotSame(newAgg, expected);
    assertEquals(expected, newAgg);
    assertEquals(expected.hashCode(), newAgg.hashCode());
}
Also used : PipelineAggregationBuilder(org.opensearch.search.aggregations.PipelineAggregationBuilder)

Aggregations

PipelineAggregationBuilder (org.opensearch.search.aggregations.PipelineAggregationBuilder)3 HashSet (java.util.HashSet)2 AggregationBuilder (org.opensearch.search.aggregations.AggregationBuilder)2