} else if (request instanceof ReindexRequest) { result = getOrReplaceAllIndices(((ReindexRequest) request).getDestination(), provider, false) && result; result = getOrReplaceAllIndices(((ReindexRequest) request).getSearchRequest(), provider, false) && result; } else if (request instanceof BaseNodesRequest) {
/** * Set the document types which need to be copied from the source indices */ public ReindexRequest setSourceDocTypes(String... docTypes) { if (docTypes != null) { this.getSearchRequest().types(docTypes); } return this; }
/** * Set the indices which will act as the source for the ReindexRequest */ public ReindexRequest setSourceIndices(String... sourceIndices) { if (sourceIndices != null) { this.getSearchRequest().indices(sourceIndices); } return this; }
/** * Sets the scroll size for setting how many documents are to be processed in one batch during reindex */ public ReindexRequest setSourceBatchSize(int size) { this.getSearchRequest().source().size(size); return this; }
/** * Add a sort against the given field name. * * @param name The name of the field to sort by * @param order The order in which to sort */ public ReindexRequest addSortField(String name, SortOrder order) { this.getSearchRequest().source().sort(name, order); return this; }
/** * Set the query for selecting documents from the source indices */ public ReindexRequest setSourceQuery(QueryBuilder queryBuilder) { if (queryBuilder != null) { this.getSearchRequest().source().query(queryBuilder); } return this; }
@Override public ActionRequestValidationException validate() { ActionRequestValidationException e = super.validate(); if (getSearchRequest().indices() == null || getSearchRequest().indices().length == 0) { e = addValidationError("use _all if you really want to copy from all existing indexes", e); if (getSearchRequest().source().fetchSource() != null && getSearchRequest().source().fetchSource().fetchSource() == false) { e = addValidationError("_source:false is not supported in this context", e); if (getSearchRequest().source().query() != null) { e = addValidationError("reindex from remote sources should use RemoteInfo's query instead of source's query", e);
public AsyncIndexBySearchAction(BulkByScrollTask task, ESLogger logger, ScriptService scriptService, Client client, ThreadPool threadPool, Version smallestNonClientVersion, ReindexRequest request, ActionListener<ReindexResponse> listener) { super(task, logger, scriptService, client, threadPool, smallestNonClientVersion, request, request.getSearchRequest(), listener); }
public AsyncIndexBySearchAction(BulkByScrollTask task, ESLogger logger, ScriptService scriptService, Client client, ThreadPool threadPool, Version smallestNonClientVersion, ReindexRequest request, ActionListener<ReindexResponse> listener) { super(task, logger, scriptService, client, threadPool, smallestNonClientVersion, request, request.getSearchRequest(), listener); }
builder.field("remote", remoteInfo); builder.array("index", getSearchRequest().indices()); builder.array("type", getSearchRequest().types()); getSearchRequest().source().innerToXContent(builder, params); builder.endObject();
/** * Set the indices which will act as the source for the ReindexRequest */ public ReindexRequest setSourceIndices(String... sourceIndices) { if (sourceIndices != null) { this.getSearchRequest().indices(sourceIndices); } return this; }
/** * Set the document types which need to be copied from the source indices */ public ReindexRequest setSourceDocTypes(String... docTypes) { if (docTypes != null) { this.getSearchRequest().types(docTypes); } return this; }
/** * Accessor to get the underlying {@link IndicesRequest}s that this request wraps. Note that this method is <strong>not * accurate</strong> since it returns a prototype {@link IndexRequest} and not the actual requests that will be issued as part of the * execution of this request. Additionally, scripts can modify the underlying {@link IndexRequest} and change values such as the index, * type, {@link org.elasticsearch.action.support.IndicesOptions}. In short - only use this for very course reasoning about the request. * * @return a list comprising of the {@link SearchRequest} and the prototype {@link IndexRequest} */ @Override public List<? extends IndicesRequest> subRequests() { assert getSearchRequest() != null; assert getDestination() != null; return Collections.<IndicesRequest>unmodifiableList(Arrays.asList(getSearchRequest(), getDestination())); } }
/** * Accessor to get the underlying {@link IndicesRequest}s that this request wraps. Note that this method is <strong>not * accurate</strong> since it returns a prototype {@link IndexRequest} and not the actual requests that will be issued as part of the * execution of this request. Additionally, scripts can modify the underlying {@link IndexRequest} and change values such as the index, * type, {@link org.elasticsearch.action.support.IndicesOptions}. In short - only use this for very course reasoning about the request. * * @return a list comprising of the {@link SearchRequest} and the prototype {@link IndexRequest} */ @Override public List<? extends IndicesRequest> subRequests() { assert getSearchRequest() != null; assert getDestination() != null; return Collections.<IndicesRequest>unmodifiableList(Arrays.asList(getSearchRequest(), getDestination())); } }
/** * Sets the scroll size for setting how many documents are to be processed in one batch during reindex */ public ReindexRequest setSourceBatchSize(int size) { this.getSearchRequest().source().size(size); return this; }
/** * Set the query for selecting documents from the source indices */ public ReindexRequest setSourceQuery(QueryBuilder queryBuilder) { if (queryBuilder != null) { this.getSearchRequest().source().query(queryBuilder); } return this; }
/** * Add a sort against the given field name. * * @param name The name of the field to sort by * @param order The order in which to sort */ public ReindexRequest addSortField(String name, SortOrder order) { this.getSearchRequest().source().sort(name, order); return this; }
@Override protected ScrollableHitSource buildScrollableResultSource(BackoffPolicy backoffPolicy) { if (mainRequest.getRemoteInfo() != null) { RemoteInfo remoteInfo = mainRequest.getRemoteInfo(); createdThreads = synchronizedList(new ArrayList<>()); RestClient restClient = buildRestClient(remoteInfo, task.getId(), createdThreads); return new RemoteScrollableHitSource(logger, backoffPolicy, threadPool, worker::countSearchRetry, this::finishHim, restClient, remoteInfo.getQuery(), mainRequest.getSearchRequest()); } return super.buildScrollableResultSource(backoffPolicy); }
@Override protected void doExecute(Task task, ReindexRequest request, ActionListener<ReindexResponse> listener) { validateAgainstAliases(request.getSearchRequest(), request.getDestination(), indexNameExpressionResolver, autoCreateIndex, clusterService.state()); new AsyncIndexBySearchAction((BulkByScrollTask) task, logger, scriptService, client, threadPool, clusterService.state().nodes().smallestNonClientNodeVersion(), request, listener).start(); }
@Override protected void doExecute(Task task, ReindexRequest request, ActionListener<ReindexResponse> listener) { validateAgainstAliases(request.getSearchRequest(), request.getDestination(), indexNameExpressionResolver, autoCreateIndex, clusterService.state()); new AsyncIndexBySearchAction((BulkByScrollTask) task, logger, scriptService, client, threadPool, clusterService.state().nodes().smallestNonClientNodeVersion(), request, listener).start(); }