BytesReference bytesReference = cacheShardLevelResult(context.indexShard(), directoryReader, request.cacheKey(), out -> { queryPhase.execute(context);
/** * Fetch {@linkplain FieldStats} for a field. These stats are cached until the shard changes. * @param shard the shard to use with the cache key * @param searcher searcher to use to lookup the field stats * @param field the actual field * @param useCache should this request use the cache? */ public FieldStats<?> getFieldStats(IndexShard shard, Engine.Searcher searcher, String field, boolean useCache) throws Exception { MappedFieldType fieldType = shard.mapperService().fullName(field); if (fieldType == null) { return null; } if (useCache == false) { return fieldType.stats(searcher.reader()); } BytesReference cacheKey = new BytesArray("fieldstats:" + field); BytesReference statsRef = cacheShardLevelResult(shard, searcher.getDirectoryReader(), cacheKey, out -> { try { out.writeOptionalWriteable(fieldType.stats(searcher.reader())); } catch (IOException e) { throw new IllegalStateException("Failed to write field stats output", e); } }); try (StreamInput in = statsRef.streamInput()) { return in.readOptionalWriteable(FieldStats::readFrom); } }
BytesReference bytesReference = cacheShardLevelResult(context.indexShard(), directoryReader, request.cacheKey(), out -> { queryPhase.execute(context); try {
BytesReference bytesReference = cacheShardLevelResult(context.indexShard(), directoryReader, request.cacheKey(), out -> { queryPhase.execute(context); try {
BytesReference bytesReference = cacheShardLevelResult(context.indexShard(), directoryReader, request.cacheKey(), out -> { queryPhase.execute(context); try {