Internal: make sure that multi_search request hands over its context and headers to its corresponding search requests
Closes #7374
This commit is contained in:
parent
b6cdaff30c
commit
f956920acc
|
@ -94,6 +94,31 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
|
||||||
public SearchRequest() {
|
public SearchRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy constructor that creates a new search request that is a copy of the one provided as an argument.
|
||||||
|
* The new request will inherit though headers and context from the original request that caused it.
|
||||||
|
*/
|
||||||
|
public SearchRequest(SearchRequest searchRequest, ActionRequest originalRequest) {
|
||||||
|
super(originalRequest);
|
||||||
|
this.searchType = searchRequest.searchType;
|
||||||
|
this.indices = searchRequest.indices;
|
||||||
|
this.routing = searchRequest.routing;
|
||||||
|
this.preference = searchRequest.preference;
|
||||||
|
this.templateSource = searchRequest.templateSource;
|
||||||
|
this.templateSourceUnsafe = searchRequest.templateSourceUnsafe;
|
||||||
|
this.templateName = searchRequest.templateName;
|
||||||
|
this.templateType = searchRequest.templateType;
|
||||||
|
this.templateParams = searchRequest.templateParams;
|
||||||
|
this.source = searchRequest.source;
|
||||||
|
this.sourceUnsafe = searchRequest.sourceUnsafe;
|
||||||
|
this.extraSource = searchRequest.extraSource;
|
||||||
|
this.extraSourceUnsafe = searchRequest.extraSourceUnsafe;
|
||||||
|
this.queryCache = searchRequest.queryCache;
|
||||||
|
this.scroll = searchRequest.scroll;
|
||||||
|
this.types = searchRequest.types;
|
||||||
|
this.indicesOptions = searchRequest.indicesOptions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new search request starting from the provided request, meaning that it will
|
* Constructs a new search request starting from the provided request, meaning that it will
|
||||||
* inherit its headers and context
|
* inherit its headers and context
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.ExceptionsHelper;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
import org.elasticsearch.action.support.TransportAction;
|
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
@ -31,8 +30,6 @@ import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.BaseTransportRequestHandler;
|
|
||||||
import org.elasticsearch.transport.TransportChannel;
|
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -61,7 +58,8 @@ public class TransportMultiSearchAction extends HandledTransportAction<MultiSear
|
||||||
final AtomicInteger counter = new AtomicInteger(responses.length());
|
final AtomicInteger counter = new AtomicInteger(responses.length());
|
||||||
for (int i = 0; i < responses.length(); i++) {
|
for (int i = 0; i < responses.length(); i++) {
|
||||||
final int index = i;
|
final int index = i;
|
||||||
searchAction.execute(request.requests().get(i), new ActionListener<SearchResponse>() {
|
SearchRequest searchRequest = new SearchRequest(request.requests().get(i), request);
|
||||||
|
searchAction.execute(searchRequest, new ActionListener<SearchResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(SearchResponse searchResponse) {
|
public void onResponse(SearchResponse searchResponse) {
|
||||||
responses.set(index, new MultiSearchResponse.Item(searchResponse, null));
|
responses.set(index, new MultiSearchResponse.Item(searchResponse, null));
|
||||||
|
|
Loading…
Reference in New Issue