use of org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality in project elasticsearch by elastic.
the class CardinalityIT method testPartiallyUnmapped.
public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "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, numDocs);
}
use of org.elasticsearch.search.aggregations.metrics.cardinality.Cardinality in project elasticsearch by elastic.
the class CardinalityIT method testMultiValuedNumericHashed.
public void testMultiValuedNumericHashed() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(true))).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 testMultiValuedNumericValueScript.
public void testMultiValuedNumericValueScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(false)).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 testMultiValuedStringScript.
public void testMultiValuedStringScript() throws Exception {
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['str_values'].values", 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 testSingleValuedNumericScript.
public void testSingleValuedNumericScript() throws Exception {
Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc[' + singleNumericField() + '].value", emptyMap());
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script(script)).execute().actionGet();
assertSearchResponse(response);
Cardinality count = response.getAggregations().get("cardinality");
assertThat(count, notNullValue());
assertThat(count.getName(), equalTo("cardinality"));
assertCount(count, numDocs);
}
Aggregations