use of org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality in project elasticsearch by elastic.
the class MissingValueIT method testCardinality.
public void testCardinality() {
SearchResponse response = client().prepareSearch("idx").addAggregation(cardinality("card").field("long").missing(2)).get();
assertSearchResponse(response);
Cardinality cardinality = response.getAggregations().get("card");
assertEquals(2, cardinality.getValue());
}
use of org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality in project elasticsearch by elastic.
the class CardinalityIT method testUnmapped.
public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_value")).execute().actionGet();
assertSearchResponse(response);
Cardinality count = response.getAggregations().get("cardinality");
assertThat(count, notNullValue());
assertThat(count.getName(), equalTo("cardinality"));
assertCount(count, 0);
}
use of org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality in project elasticsearch by elastic.
the class CardinalityIT method testSingleValuedNumericValueScript.
public void testSingleValuedNumericValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(singleNumericField()).script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value", emptyMap()))).execute().actionGet();
assertSearchResponse(response);
Cardinality count = response.getAggregations().get("cardinality");
assertThat(count, notNullValue());
assertThat(count.getName(), equalTo("cardinality"));
assertCount(count, numDocs);
}
use of org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality in project elasticsearch by elastic.
the class CardinalityIT method testMultiValuedStringValueScript.
public void testMultiValuedStringValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_values").script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value", emptyMap()))).execute().actionGet();
assertSearchResponse(response);
Cardinality count = response.getAggregations().get("cardinality");
assertThat(count, notNullValue());
assertThat(count.getName(), equalTo("cardinality"));
assertCount(count, numDocs * 2);
}
use of org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality in project elasticsearch by elastic.
the class CardinalityIT method testMultiValuedNumeric.
public void testMultiValuedNumeric() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(false))).execute().actionGet();
assertSearchResponse(response);
Cardinality count = response.getAggregations().get("cardinality");
assertThat(count, notNullValue());
assertThat(count.getName(), equalTo("cardinality"));
assertCount(count, numDocs * 2);
}
Aggregations