use of org.elasticsearch.search.aggregations.metrics.min.Min in project elasticsearch by elastic.
the class MinIT method testScriptSingleValued.
@Override
public void testScriptSingleValued() throws Exception {
Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap());
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(min("min").script(script)).get();
assertHitCount(searchResponse, 10);
Min min = searchResponse.getAggregations().get("min");
assertThat(min, notNullValue());
assertThat(min.getName(), equalTo("min"));
assertThat(min.getValue(), equalTo(1.0));
}
use of org.elasticsearch.search.aggregations.metrics.min.Min in project elasticsearch by elastic.
the class MinIT method testSingleValuedField.
@Override
public void testSingleValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(min("min").field("value")).execute().actionGet();
assertHitCount(searchResponse, 10);
Min min = searchResponse.getAggregations().get("min");
assertThat(min, notNullValue());
assertThat(min.getName(), equalTo("min"));
assertThat(min.getValue(), equalTo(1.0));
}
use of org.elasticsearch.search.aggregations.metrics.min.Min in project elasticsearch by elastic.
the class MinIT method testScriptMultiValued.
@Override
public void testScriptMultiValued() throws Exception {
Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values'].values", emptyMap());
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(min("min").script(script)).get();
assertHitCount(searchResponse, 10);
Min min = searchResponse.getAggregations().get("min");
assertThat(min, notNullValue());
assertThat(min.getName(), equalTo("min"));
assertThat(min.getValue(), equalTo(2.0));
}
use of org.elasticsearch.search.aggregations.metrics.min.Min in project elasticsearch by elastic.
the class MinIT method testMultiValuedField.
@Override
public void testMultiValuedField() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(min("min").field("values")).execute().actionGet();
assertHitCount(searchResponse, 10);
Min min = searchResponse.getAggregations().get("min");
assertThat(min, notNullValue());
assertThat(min.getName(), equalTo("min"));
assertThat(min.getValue(), equalTo(2.0));
}
use of org.elasticsearch.search.aggregations.metrics.min.Min in project elasticsearch by elastic.
the class MinIT method testSingleValuedFieldWithValueScript.
@Override
public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(min("min").field("value").script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))).get();
assertHitCount(searchResponse, 10);
Min min = searchResponse.getAggregations().get("min");
assertThat(min, notNullValue());
assertThat(min.getName(), equalTo("min"));
assertThat(min.getValue(), equalTo(0.0));
}
Aggregations