final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullHistogramFacet.FullEntry[entries.size()]; return new InternalCountHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountDateHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullDateHistogramFacet.FullEntry[entries.size()]; return new InternalCountDateHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullDateHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullHistogramFacet.FullEntry[entries.size()]; return new InternalCountHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountDateHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullDateHistogramFacet.FullEntry[entries.size()]; return new InternalCountDateHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullDateHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
checkState(stringEntries == null && longEntries == null); return new InternalDoubleTermsFacet(facetName, comparatorType, doubleEntries.size(), doubleEntries, missing, total); } else if (stringEntries != null) { checkState(longEntries == null); return new InternalStringTermsFacet(facetName, comparatorType, stringEntries.size(), stringEntries, missing, total); } else if (longEntries != null) { return new InternalLongTermsFacet(facetName, comparatorType, longEntries.size(), longEntries, missing, total); } else { checkState(terms.isEmpty());
checkState(stringEntries == null && longEntries == null); return new InternalDoubleTermsFacet(facetName, comparatorType, doubleEntries.size(), doubleEntries, missing, total); } else if (stringEntries != null) { checkState(longEntries == null); return new InternalStringTermsFacet(facetName, comparatorType, stringEntries.size(), stringEntries, missing, total); } else if (longEntries != null) { return new InternalLongTermsFacet(facetName, comparatorType, longEntries.size(), longEntries, missing, total); } else { checkState(terms.isEmpty());
private static ShardSearchFailure[] getShardSearchFailures(final Map<String, Object> shards, final int failedShards) { final ShardSearchFailure[] shardSearchFailures = new ShardSearchFailure[failedShards]; if (failedShards == 0) { Preconditions.checkState(!shards.containsKey("failures")); return shardSearchFailures; } Object[] failures = nodeListValue(shards.get("failures"), Object.class).toArray(); for (int i = 0; i < failedShards; i++) { Map<String, Object> failure = nodeMapValue(failures[i], String.class, Object.class); SearchShardTarget shard = null; if (failure.containsKey("index") && failure.containsKey("shard")) { String index = nodeStringValue(failure.get("index"), null); Integer shardId = nodeIntegerValue(failure.get("shard")); shard = new SearchShardTarget(null, index, shardId); } shardSearchFailures[i] = new ShardSearchFailure( nodeStringValue(failure.get("reason"), null), shard, findRestStatus(nodeIntegerValue(failure.get("status"))) ); } return shardSearchFailures; }
private static ShardSearchFailure[] getShardSearchFailures(final Map<String, Object> shards, final int failedShards) { final ShardSearchFailure[] shardSearchFailures = new ShardSearchFailure[failedShards]; if (failedShards == 0) { Preconditions.checkState(!shards.containsKey("failures")); return shardSearchFailures; } Object[] failures = nodeListValue(shards.get("failures"), Object.class).toArray(); for (int i = 0; i < failedShards; i++) { Map<String, Object> failure = nodeMapValue(failures[i], String.class, Object.class); SearchShardTarget shard = null; if (failure.containsKey("index") && failure.containsKey("shard")) { String index = nodeStringValue(failure.get("index"), null); Integer shardId = nodeIntegerValue(failure.get("shard")); shard = new SearchShardTarget(null, index, shardId); } shardSearchFailures[i] = new ShardSearchFailure( nodeStringValue(failure.get("reason"), null), shard, findRestStatus(nodeIntegerValue(failure.get("status"))) ); } return shardSearchFailures; }
checkState(stringEntries == null && longEntries == null); return new InternalTermsStatsDoubleFacet(facetName, comparatorType, doubleEntries.size(), doubleEntries, missing); } else if (stringEntries != null) { checkState(longEntries == null); return new InternalTermsStatsStringFacet(facetName, comparatorType, stringEntries.size(), stringEntries, missing); } else if (longEntries != null) { return new InternalTermsStatsLongFacet(facetName, comparatorType, longEntries.size(), longEntries, missing); } else { checkState(terms.isEmpty());
checkState(stringEntries == null && longEntries == null); return new InternalTermsStatsDoubleFacet(facetName, comparatorType, doubleEntries.size(), doubleEntries, missing); } else if (stringEntries != null) { checkState(longEntries == null); return new InternalTermsStatsStringFacet(facetName, comparatorType, stringEntries.size(), stringEntries, missing); } else if (longEntries != null) { return new InternalTermsStatsLongFacet(facetName, comparatorType, longEntries.size(), longEntries, missing); } else { checkState(terms.isEmpty());
Preconditions.checkState(suggest.size() == 1);
Preconditions.checkState(suggest.size() == 1);
public static SignificantTerms.Bucket fromXContent(final long aggDocCount, final Map<String, Object> map, final AggregationsManifest manifest) { final Object untypedTerm = map.get(KEY); final long bucketDocCount = nodeLongValue(map.get(DOC_COUNT)); final long bucketBgCount = nodeLongValue(map.get(BG_COUNT)); final double score = nodeDoubleValue(map.get(SCORE)); final Map<String, Object> subAggsMap = Maps.filterKeys(map, new Predicate<String>() { @Override public boolean apply(final String s) { return !properKeys.contains(s); } }); final Aggregations aggregations = InternalAggregationsHelper.fromXContentUnwrapped(subAggsMap, manifest); if (untypedTerm instanceof String) { return new ComputedSignificantStringTermsBucket(new BytesRef(nodeStringValue(untypedTerm)), bucketDocCount, aggDocCount, bucketBgCount, score, aggregations); } else { checkState(untypedTerm instanceof Number); //noinspection ConstantConditions return new ComputedSignificantNumberTermsBucket((Number) untypedTerm, bucketDocCount, aggDocCount, bucketBgCount, score, aggregations); } }
public static SignificantTerms.Bucket fromXContent(final long aggDocCount, final Map<String, Object> map, final AggregationsManifest manifest) { final Object untypedTerm = map.get(KEY); final long bucketDocCount = nodeLongValue(map.get(DOC_COUNT)); final long bucketBgCount = nodeLongValue(map.get(BG_COUNT)); final double score = nodeDoubleValue(map.get(SCORE)); final Map<String, Object> subAggsMap = Maps.filterKeys(map, new Predicate<String>() { @Override public boolean apply(final String s) { return !properKeys.contains(s); } }); final Aggregations aggregations = InternalAggregationsHelper.fromXContentUnwrapped(subAggsMap, manifest); if (untypedTerm instanceof String) { return new ComputedSignificantStringTermsBucket(new BytesRef(nodeStringValue(untypedTerm)), bucketDocCount, aggDocCount, bucketBgCount, score, aggregations); } else { checkState(untypedTerm instanceof Number); //noinspection ConstantConditions return new ComputedSignificantNumberTermsBucket((Number) untypedTerm, bucketDocCount, aggDocCount, bucketBgCount, score, aggregations); } }