use of org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder in project elasticsearch by elastic.
the class SamplerIT method testUnmappedChildAggNoDiversity.
public void testUnmappedChildAggNoDiversity() throws Exception {
SamplerAggregationBuilder sampleAgg = sampler("sample").shardSize(100);
sampleAgg.subAggregation(terms("authors").field("author"));
SearchResponse response = client().prepareSearch("idx_unmapped").setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(new TermQueryBuilder("genre", "fantasy")).setFrom(0).setSize(60).addAggregation(sampleAgg).execute().actionGet();
assertSearchResponse(response);
Sampler sample = response.getAggregations().get("sample");
assertThat(sample.getDocCount(), equalTo(0L));
Terms authors = sample.getAggregations().get("authors");
assertThat(authors.getBuckets().size(), equalTo(0));
}
use of org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder in project elasticsearch by elastic.
the class SamplerIT method testSimpleSampler.
public void testSimpleSampler() throws Exception {
SamplerAggregationBuilder sampleAgg = sampler("sample").shardSize(100);
sampleAgg.subAggregation(terms("authors").field("author"));
SearchResponse response = client().prepareSearch("test").setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(new TermQueryBuilder("genre", "fantasy")).setFrom(0).setSize(60).addAggregation(sampleAgg).execute().actionGet();
assertSearchResponse(response);
Sampler sample = response.getAggregations().get("sample");
Terms authors = sample.getAggregations().get("authors");
Collection<Bucket> testBuckets = authors.getBuckets();
long maxBooksPerAuthor = 0;
for (Terms.Bucket testBucket : testBuckets) {
maxBooksPerAuthor = Math.max(testBucket.getDocCount(), maxBooksPerAuthor);
}
assertThat(maxBooksPerAuthor, equalTo(3L));
}
use of org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder in project fess by codelibs.
the class EsAbstractConditionAggregation method regSamplerA.
protected SamplerAggregationBuilder regSamplerA(String name) {
SamplerAggregationBuilder builder = AggregationBuilders.sampler(name);
regA(builder);
return builder;
}
use of org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder in project fess by codelibs.
the class BsAccessTokenCA method sampler.
public void sampler(String name, ConditionOptionCall<SamplerAggregationBuilder> opLambda, OperatorCall<BsAccessTokenCA> aggsLambda) {
SamplerAggregationBuilder builder = regSamplerA(name);
if (opLambda != null) {
opLambda.callback(builder);
}
if (aggsLambda != null) {
AccessTokenCA ca = new AccessTokenCA();
aggsLambda.callback(ca);
ca.getAggregationBuilderList().forEach(builder::subAggregation);
}
}
use of org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder in project fess by codelibs.
the class BsBadWordCA method sampler.
public void sampler(String name, ConditionOptionCall<SamplerAggregationBuilder> opLambda, OperatorCall<BsBadWordCA> aggsLambda) {
SamplerAggregationBuilder builder = regSamplerA(name);
if (opLambda != null) {
opLambda.callback(builder);
}
if (aggsLambda != null) {
BadWordCA ca = new BadWordCA();
aggsLambda.callback(ca);
ca.getAggregationBuilderList().forEach(builder::subAggregation);
}
}
Aggregations