Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reindex remove outer level size #43373

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 @@ -427,11 +427,7 @@ public void testReindex() throws IOException {
reindexRequest.setDestRouting("=cat");
}
if (randomBoolean()) {
if (randomBoolean()) {
reindexRequest.setMaxDocs(randomIntBetween(100, 1000));
} else {
reindexRequest.setSize(randomIntBetween(100, 1000));
}
reindexRequest.setMaxDocs(randomIntBetween(100, 1000));
}
if (randomBoolean()) {
reindexRequest.setAbortOnVersionConflict(false);
Expand Down Expand Up @@ -479,13 +475,9 @@ public void testUpdateByQuery() throws IOException {
expectedParams.put("routing", "=cat");
}
if (randomBoolean()) {
int size = randomIntBetween(100, 1000);
if (randomBoolean()) {
updateByQueryRequest.setMaxDocs(size);
} else {
updateByQueryRequest.setSize(size);
}
expectedParams.put("max_docs", Integer.toString(size));
int maxDocs = randomIntBetween(100, 1000);
updateByQueryRequest.setMaxDocs(maxDocs);
expectedParams.put("max_docs", Integer.toString(maxDocs));
}
if (randomBoolean()) {
updateByQueryRequest.setAbortOnVersionConflict(false);
Expand Down Expand Up @@ -528,13 +520,9 @@ public void testDeleteByQuery() throws IOException {
expectedParams.put("routing", "=cat");
}
if (randomBoolean()) {
int size = randomIntBetween(100, 1000);
if (randomBoolean()) {
deleteByQueryRequest.setMaxDocs(size);
} else {
deleteByQueryRequest.setSize(size);
}
expectedParams.put("max_docs", Integer.toString(size));
int maxDocs = randomIntBetween(100, 1000);
deleteByQueryRequest.setMaxDocs(maxDocs);
expectedParams.put("max_docs", Integer.toString(maxDocs));
}
if (randomBoolean()) {
deleteByQueryRequest.setAbortOnVersionConflict(false);
Expand Down
16 changes: 15 additions & 1 deletion docs/reference/migration/migrate_8_0/reindex.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,18 @@ Instead, please specify the index-name without any encoding.
[float]
==== Removal of types

The `/{index}/{type}/_delete_by_query` and `/{index}/{type}/_update_by_query` REST endpoints have been removed in favour of `/{index}/_delete_by_query` and `/{index}/_update_by_query`, since indexes no longer contain types, these typed endpoints are obsolete.
The `/{index}/{type}/_delete_by_query` and `/{index}/{type}/_update_by_query` REST endpoints have been removed in favour of `/{index}/_delete_by_query` and `/{index}/_update_by_query`, since indexes no longer contain types, these typed endpoints are obsolete.

[float]
==== Removal of size parameter

Previously, a `_reindex` request had two different size specifications in the body:

- Outer level, determining the maximum number of documents to process
- Inside the `source` element, determining the scroll/batch size.

The outer level `size` parameter has now been renamed to `max_docs` to
avoid confusion and clarify its semantics.

Similarly, the `size` parameter has been renamed to `max_docs` for
`_delete_by_query` and `_update_by_query` to keep the 3 interfaces consistent.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
Expand Down Expand Up @@ -53,7 +52,7 @@ protected void parseInternalRequest(Request internal, RestRequest restRequest,
SearchRequest searchRequest = internal.getSearchRequest();

try (XContentParser parser = extractRequestSpecificFields(restRequest, bodyConsumers)) {
RestSearchAction.parseSearchRequest(searchRequest, restRequest, parser, size -> setMaxDocsFromSearchSize(internal, size));
RestSearchAction.parseSearchRequest(searchRequest, restRequest, parser, size -> failOnSizeSpecified());
}

searchRequest.source().size(restRequest.paramAsInt("scroll_size", searchRequest.source().size()));
Expand Down Expand Up @@ -96,8 +95,7 @@ private XContentParser extractRequestSpecificFields(RestRequest restRequest,
}
}

private void setMaxDocsFromSearchSize(Request request, int size) {
LoggingDeprecationHandler.INSTANCE.usedDeprecatedName("size", "max_docs");
setMaxDocsValidateIdentical(request, size);
private static void failOnSizeSpecified() {
throw new IllegalArgumentException("invalid parameter [size], use [max_docs] instead");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ private void randomRequest(AbstractBulkByScrollRequest<?> request) {
request.getSearchRequest().indices("test");
request.getSearchRequest().source().size(between(1, 1000));
if (randomBoolean()) {
if (randomBoolean()) {
request.setMaxDocs(between(1, Integer.MAX_VALUE));
} else {
request.setSize(between(1, Integer.MAX_VALUE));
}
request.setMaxDocs(between(1, Integer.MAX_VALUE));
}
request.setAbortOnVersionConflict(random().nextBoolean());
request.setRefresh(rarely());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,52 +279,6 @@

- match: {count: 1}

---
"Limit by size":
- skip:
version: " - 7.2.99"
reason: "deprecation warnings only emitted on 7.3+"
features: warnings

- do:
index:
index: twitter
id: 1
body: { "user": "kimchy" }
- do:
index:
index: twitter
id: 2
body: { "user": "kimchy" }
- do:
indices.refresh: {}

- do:
warnings:
- Deprecated field [size] used, expected [max_docs] instead
delete_by_query:
index: twitter
size: 1
body:
query:
match_all: {}

- match: {deleted: 1}
- match: {version_conflicts: 0}
- match: {batches: 1}
- match: {failures: []}
- match: {throttled_millis: 0}
- gte: { took: 0 }

- do:
indices.refresh: {}

- do:
count:
index: twitter

- match: {count: 1}

---
"Limit by size pre 7.3":
- skip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@
query:
match_all: {}

---
"invalid size fails":
- do:
index:
index: test
id: 1
body: { "text": "test" }
- do:
catch: /\[max_docs\] parameter cannot be negative, found \[-4\]/
delete_by_query:
index: test
size: -4
body:
query:
match_all: {}

---
"invalid max_docs fails":
- skip:
Expand All @@ -66,27 +50,6 @@
query:
match_all: {}

---
"both max_docs and size fails":
- skip:
version: " - 7.2.99"
reason: "max_docs introduced in 7.3.0"

- do:
index:
index: test
id: 1
body: { "text": "test" }
- do:
catch: /\[max_docs\] set to two different values \[4\] and \[5\]/
delete_by_query:
index: test
size: 4
max_docs: 5
body:
query:
match_all: {}

---
"invalid scroll_size fails":
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,26 @@
conflicts: cat

---
"invalid size fails":
"specifying size fails":
- skip:
version: " - 7.99.99"
reason: "size supported until 8"

- do:
index:
index: test
id: 1
body: { "text": "test" }
index: test
id: 1
body: { "text": "test" }

- do:
catch: /\[max_docs\] parameter cannot be negative, found \[-4\]/
catch: /invalid parameter \[size\], use \[max_docs\] instead/
reindex:
body:
source:
index: test
dest:
index: dest
size: -4
size: 1

---
"invalid max_docs in body fails":
Expand Down Expand Up @@ -153,28 +158,6 @@
dest:
index: dest

---
"inconsistent max_docs and size fails":
- skip:
version: " - 7.2.99"
reason: "max_docs introduced in 7.3.0"

- do:
index:
index: test
id: 1
body: { "text": "test" }
- do:
catch: /\[max_docs\] set to two different values \[4\] and \[5\]/
reindex:
body:
source:
index: test
dest:
index: dest
size: 4
max_docs: 5

---
"inconsistent max_docs in body and max_docs in URL fails":
- skip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,52 +31,6 @@
index: target
- match: { hits.total: 1 }

---
"Sorting and size combined":
- skip:
version: " - 7.2.99"
reason: "deprecation warnings only emitted on 7.3+"
features: warnings

- do:
index:
index: test
id: 1
body: { "order": 1 }
- do:
index:
index: test
id: 2
body: { "order": 2 }
- do:
indices.refresh: {}

- do:
warnings:
- Deprecated field [size] used, expected [max_docs] instead
reindex:
refresh: true
body:
size: 1
source:
index: test
sort: order
dest:
index: target

- do:
search:
rest_total_hits_as_int: true
index: target
- match: { hits.total: 1 }

- do:
search:
rest_total_hits_as_int: true
index: target
q: order:1
- match: { hits.total: 1 }

---
"Sorting and size combined pre 7.3":
- skip:
Expand Down
Loading