use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class AbstractBulkByScrollRequest method readFrom.
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
searchRequest = new SearchRequest();
searchRequest.readFrom(in);
abortOnVersionConflict = in.readBoolean();
size = in.readVInt();
refresh = in.readBoolean();
timeout = new TimeValue(in);
activeShardCount = ActiveShardCount.readFrom(in);
retryBackoffInitialTime = new TimeValue(in);
maxRetries = in.readVInt();
requestsPerSecond = in.readFloat();
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
slices = in.readVInt();
} else {
slices = 1;
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class BulkByScrollParallelizationHelper method startSlices.
public static <Request extends AbstractBulkByScrollRequest<Request>> void startSlices(Client client, TaskManager taskManager, Action<Request, BulkByScrollResponse, ?> action, String localNodeId, ParentBulkByScrollTask task, Request request, ActionListener<BulkByScrollResponse> listener) {
TaskId parentTaskId = new TaskId(localNodeId, task.getId());
for (final SearchRequest slice : sliceIntoSubRequests(request.getSearchRequest(), UidFieldMapper.NAME, request.getSlices())) {
// TODO move the request to the correct node. maybe here or somehow do it as part of startup for reindex in general....
Request requestForSlice = request.forSlice(parentTaskId, slice);
ActionListener<BulkByScrollResponse> sliceListener = ActionListener.wrap(r -> task.onSliceResponse(listener, slice.source().slice().getId(), r), e -> task.onSliceFailure(listener, slice.source().slice().getId(), e));
client.execute(action, requestForSlice, sliceListener);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class AsyncBulkByScrollActionTests method setupForTest.
@Before
public void setupForTest() {
// Fill the context with something random so we can make sure we inherited it appropriately.
expectedHeaders.clear();
expectedHeaders.put(randomSimpleString(random()), randomSimpleString(random()));
setupClient(new TestThreadPool(getTestName()));
firstSearchRequest = new SearchRequest();
testRequest = new DummyAbstractBulkByScrollRequest(firstSearchRequest);
listener = new PlainActionFuture<>();
scrollId = null;
taskManager = new TaskManager(Settings.EMPTY);
testTask = (WorkingBulkByScrollTask) taskManager.register("don'tcare", "hereeither", testRequest);
localNode = new DiscoveryNode("thenode", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
taskId = new TaskId(localNode.getId(), testTask.getId());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class BulkByScrollParallelizationHelperTests method testSliceIntoSubRequests.
public void testSliceIntoSubRequests() throws IOException {
SearchRequest searchRequest = randomSearchRequest(() -> randomSearchSourceBuilder(() -> null, () -> null, () -> null, () -> emptyList(), () -> null));
if (searchRequest.source() != null) {
// Clear the slice builder if there is one set. We can't call sliceIntoSubRequests if it is.
searchRequest.source().slice(null);
}
int times = between(2, 100);
String field = randomBoolean() ? UidFieldMapper.NAME : randomAsciiOfLength(5);
int currentSliceId = 0;
for (SearchRequest slice : sliceIntoSubRequests(searchRequest, field, times)) {
assertEquals(field, slice.source().slice().getField());
assertEquals(currentSliceId, slice.source().slice().getId());
assertEquals(times, slice.source().slice().getMax());
// If you clear the slice then the slice should be the same request as the parent request
slice.source().slice(null);
if (searchRequest.source() == null) {
// Except that adding the slice might have added an empty builder
searchRequest.source(new SearchSourceBuilder());
}
assertEquals(searchRequest, slice);
currentSliceId++;
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest in project elasticsearch by elastic.
the class DeleteByQueryRequestTests method testTypesGetter.
public void testTypesGetter() {
int numTypes = between(1, 50);
String[] types = new String[numTypes];
for (int i = 0; i < numTypes; i++) {
types[i] = randomSimpleString(random(), 1, 30);
}
SearchRequest searchRequest = new SearchRequest();
searchRequest.types(types);
DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest);
assertArrayEquals(request.types(), types);
}
Aggregations