@Test public void search() { ElasticsearchNodeClient client = new ElasticsearchNodeClient(mock(ClusterService.class), nodeClient); SearchResponse searchResponse = mock(SearchResponse.class); when(nodeClient.search(any()).actionGet()).thenReturn(searchResponse); when(searchResponse.getScrollId()).thenReturn("scroll123"); when(searchResponse.getHits()) .thenReturn( new SearchHits( new SearchHit[] {searchHit}, new TotalHits(1L, TotalHits.Relation.EQUAL_TO), 1.0F)); when(searchHit.getSourceAsString()).thenReturn("{\"id\", 1}"); when(factory.construct(any())).thenReturn(exprTupleValue); SearchResponse scrollResponse = mock(SearchResponse.class); when(nodeClient.searchScroll(any()).actionGet()).thenReturn(scrollResponse); when(scrollResponse.getScrollId()).thenReturn("scroll456"); when(scrollResponse.getHits()).thenReturn(SearchHits.empty()); ElasticsearchScrollRequest request = new ElasticsearchScrollRequest("test", factory); ElasticsearchResponse response1 = client.search(request); assertFalse(response1.isEmpty()); Iterator<ExprValue> hits = response1.iterator(); assertTrue(hits.hasNext()); assertEquals(exprTupleValue, hits.next()); assertFalse(hits.hasNext()); ElasticsearchResponse response2 = client.search(request); assertTrue(response2.isEmpty()); }
@Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> client.search(req).actionGet(), req -> client.searchScroll(req).actionGet() ); }
ElasticsearchNodeClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> client.search(req).actionGet(), req -> client.searchScroll(req).actionGet() ); } }
ElasticsearchNodeClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> client.search(req).actionGet(), req -> client.searchScroll(req).actionGet() ); }  }
ElasticsearchNodeClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> client.search(req).actionGet(), req -> client.searchScroll(req).actionGet() ); }  @Override Map<String, IndexMapping> getIndexMappings(String indexExpression); @Override ElasticsearchResponse search(ElasticsearchRequest request); @Override void cleanup(ElasticsearchRequest request); @Override void schedule(Runnable task); }
ElasticsearchNodeClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> client.search(req).actionGet(), req -> client.searchScroll(req).actionGet() ); }  @Override Map<String, IndexMapping> getIndexMappings(String indexExpression); @Override ElasticsearchResponse search(ElasticsearchRequest request); @Override void cleanup(ElasticsearchRequest request); @Override void schedule(Runnable task); static final String[] ALL_TYPES; static final Function<String, Predicate<String>> ALL_FIELDS; }