@Override public ActionFuture<SearchResponse> searchScroll(final SearchScrollRequest request) { return execute(SearchScrollAction.INSTANCE, request); }
@Override public void searchScroll(final SearchScrollRequest request, final ActionListener<SearchResponse> listener) { execute(SearchScrollAction.INSTANCE, request, listener); }
@Override public SearchScrollRequestBuilder prepareSearchScroll(String scrollId) { return new SearchScrollRequestBuilder(this, SearchScrollAction.INSTANCE, scrollId); }
public void testCancellationOfScrollSearchesOnFollowupRequests() throws Exception { List<ScriptedBlockPlugin> plugins = initBlockFactory(); indexTestData(); // Disable block so the first request would pass disableBlocks(plugins); logger.info("Executing search"); TimeValue keepAlive = TimeValue.timeValueSeconds(5); SearchResponse searchResponse = client().prepareSearch("test") .setScroll(keepAlive) .setSize(2) .setQuery( scriptQuery(new Script( ScriptType.INLINE, "native", NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, Collections.emptyMap()))) .get(); assertNotNull(searchResponse.getScrollId()); // Enable block so the second request would block for (ScriptedBlockPlugin plugin : plugins) { plugin.scriptedBlockFactory.reset(); plugin.scriptedBlockFactory.enableBlock(); } String scrollId = searchResponse.getScrollId(); logger.info("Executing scroll with id {}", scrollId); ListenableActionFuture<SearchResponse> scrollResponse = client().prepareSearchScroll(searchResponse.getScrollId()) .setScroll(keepAlive).execute(); awaitForBlock(plugins); cancelSearch(SearchScrollAction.NAME); disableBlocks(plugins); SearchResponse response = ensureSearchWasCancelled(scrollResponse); if (response != null) { // The response didn't fail completely - update scroll id scrollId = response.getScrollId(); } logger.info("Cleaning scroll with id {}", scrollId); client().prepareClearScroll().addScrollId(scrollId).get(); }
public SearchScrollAction getAction() { return SearchScrollAction.INSTANCE; }