Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/modules/indices/request_cache.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ query-string parameter detailed here.
[discrete]
==== Cache key

The whole JSON body is used as the cache key. This means that if the JSON
A hash of the whole JSON body is used as the cache key. This means that if the JSON
changes -- for instance if keys are output in a different order -- then the
cache key will not be recognised.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import org.elasticsearch.core.CheckedFunction;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.hash.MessageDigests;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -404,8 +406,7 @@ public BytesReference cacheKey(CheckedBiConsumer<ShardSearchRequest, StreamOutpu
if (differentiator != null) {
differentiator.accept(this, out);
}
// copy it over since we don't want to share the thread-local bytes in #scratch
return out.copyBytes();
return new BytesArray(MessageDigests.digest(out.bytes(), MessageDigests.sha256()));
} finally {
out.reset();
}
Expand Down