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
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ public ActionRequestValidationException validate() {
validationException =
addValidationError("using [from] is not allowed in a scroll context", validationException);
}
if (requestCache != null && requestCache && scroll() != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this will not be backported to 6.x and instead we will print a deprecation log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that's the plan

validationException =
addValidationError("[request_cache] cannot be used in a a scroll context", validationException);
}
return validationException;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,12 @@ public void close() {
* Can the shard request be cached at all?
*/
public boolean canCache(ShardSearchRequest request, SearchContext context) {
// Queries that create a scroll context cannot use the cache.
// They modify the search context during their execution so using the cache
// may invalidate the scroll for the next query.
if (request.scroll() != null) {
return false;
}

// We cannot cache with DFS because results depend not only on the content of the index but also
// on the overridden statistics. So if you ran two queries on the same index with different stats
Expand All @@ -1080,6 +1086,7 @@ public boolean canCache(ShardSearchRequest request, SearchContext context) {
if (SearchType.QUERY_THEN_FETCH != context.searchType()) {
return false;
}

IndexSettings settings = context.indexShard().indexSettings();
// if not explicitly set in the request, use the index setting, if not, use the request
if (request.requestCache() == null) {
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/migration/migrate_7_0/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ The Search API returns `400 - Bad request` while it would previously return
* the number of slices is too large
* keep alive for scroll is too large
* number of filters in the adjacency matrix aggregation is too large


==== Scroll queries cannot use the request_cache anymore

Setting `request_cache:true` on a query that creates a scroll ('scroll=1m`)
has been deprecated in 6 and will now return a `400 - Bad request`.
Scroll queries are not meant to be cached.
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,20 @@
clear_scroll:
scroll_id: $scroll_id

---
"Scroll cannot used the request cache":
- skip:
version: " - 6.99.99"
reason: the error message has been added in v7.0.0
- do:
indices.create:
index: test_scroll
- do:
catch: /\[request_cache\] cannot be used in a a scroll context/
search:
index: test_scroll
scroll: 1m
request_cache: true
body:
query:
match_all: {}