HLRC: Fix Reindex from remote query logic (#36908)
The query object was incorrectly added to the remote object in the xcontent. This fix moves the query back into the source, if it was passed in as part of the RemoteInfo. It also adds a IPv6 test for reindex from remote such that we can properly validate this.
This commit is contained in:
parent
e38cf1d0dc
commit
e40193ae66
|
@ -103,6 +103,7 @@ integTestRunner {
|
|||
|
||||
integTestCluster {
|
||||
systemProperty 'es.scripting.update.ctx_in_params', 'false'
|
||||
setting 'reindex.remote.whitelist', '"[::1]:*"'
|
||||
setting 'xpack.license.self_generated.type', 'trial'
|
||||
setting 'xpack.security.enabled', 'true'
|
||||
setting 'xpack.security.authc.token.enabled', 'true'
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.client.documentation;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.DocWriteRequest;
|
||||
|
@ -823,9 +824,6 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// tag::reindex-request-conflicts
|
||||
request.setConflicts("proceed"); // <1>
|
||||
// end::reindex-request-conflicts
|
||||
// tag::reindex-request-query
|
||||
request.setSourceQuery(new TermQueryBuilder("user", "kimchy")); // <1>
|
||||
// end::reindex-request-query
|
||||
// tag::reindex-request-size
|
||||
request.setSize(10); // <1>
|
||||
// end::reindex-request-size
|
||||
|
@ -846,27 +844,29 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
"if (ctx._source.user == 'kimchy') {ctx._source.likes++;}",
|
||||
Collections.emptyMap())); // <1>
|
||||
// end::reindex-request-script
|
||||
HttpHost host = getClusterHosts().get(0);
|
||||
Integer remotePort = host.getPort();
|
||||
String remoteHost = host.getHostName();
|
||||
String user = "test_user";
|
||||
String password = "test-password";
|
||||
|
||||
// tag::reindex-request-remote
|
||||
request.setRemoteInfo(
|
||||
new RemoteInfo(
|
||||
"https", "localhost", 9002, null,
|
||||
"http", remoteHost, remotePort, null,
|
||||
new BytesArray(new MatchAllQueryBuilder().toString()),
|
||||
"user", "pass", Collections.emptyMap(),
|
||||
user, password, Collections.emptyMap(),
|
||||
new TimeValue(100, TimeUnit.MILLISECONDS),
|
||||
new TimeValue(100, TimeUnit.SECONDS)
|
||||
)
|
||||
); // <1>
|
||||
// end::reindex-request-remote
|
||||
request.setRemoteInfo(null); // Remove it for tests
|
||||
// tag::reindex-request-timeout
|
||||
request.setTimeout(TimeValue.timeValueMinutes(2)); // <1>
|
||||
// end::reindex-request-timeout
|
||||
// tag::reindex-request-refresh
|
||||
request.setRefresh(true); // <1>
|
||||
// end::reindex-request-refresh
|
||||
// tag::reindex-request-slices
|
||||
request.setSlices(2); // <1>
|
||||
// end::reindex-request-slices
|
||||
// tag::reindex-request-scroll
|
||||
request.setScroll(TimeValue.timeValueMinutes(10)); // <1>
|
||||
// end::reindex-request-scroll
|
||||
|
@ -904,6 +904,14 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
request.setSourceIndices("source1");
|
||||
request.setDestIndex("dest");
|
||||
|
||||
// These cannot be set with a remote set, so its set here instead for the docs
|
||||
// tag::reindex-request-query
|
||||
request.setSourceQuery(new TermQueryBuilder("user", "kimchy")); // <1>
|
||||
// end::reindex-request-query
|
||||
// tag::reindex-request-slices
|
||||
request.setSlices(2); // <1>
|
||||
// end::reindex-request-slices
|
||||
|
||||
ActionListener<BulkByScrollResponse> listener;
|
||||
// tag::reindex-execute-listener
|
||||
listener = new ActionListener<BulkByScrollResponse>() {
|
||||
|
|
|
@ -293,6 +293,7 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest<ReindexRequ
|
|||
builder.startObject("source");
|
||||
if (remoteInfo != null) {
|
||||
builder.field("remote", remoteInfo);
|
||||
builder.rawField("query", remoteInfo.getQuery().streamInput(), builder.contentType());
|
||||
}
|
||||
builder.array("index", getSearchRequest().indices());
|
||||
String[] types = getSearchRequest().types();
|
||||
|
|
|
@ -209,7 +209,6 @@ public class RemoteInfo implements Writeable, ToXContentObject {
|
|||
}
|
||||
builder.field("socket_timeout", socketTimeout.getStringRep());
|
||||
builder.field("connect_timeout", connectTimeout.getStringRep());
|
||||
builder.field("query", query);
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue