org.elasticsearch.action.search.SearchResponseSections Java Examples
The following examples show how to use
org.elasticsearch.action.search.SearchResponseSections.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestQueryUtil.java From blue-marlin with Apache License 2.0 | 5 votes |
@Test public void extractAggregationValue() { int docId = 0, docId1 = 1, docId2 = 2, docId3 = 3, docId4 = 400, docId5 = 5000; SearchHit[] hit = new SearchHit[6]; hit[0] = new SearchHit(docId); hit[1] = new SearchHit(docId1); hit[2] = new SearchHit(docId2); hit[3] = new SearchHit(docId3); hit[4] = new SearchHit(docId4); hit[5] = new SearchHit(docId5); SearchHits hits = new SearchHits(hit, 30000, 450); Aggregations aggregations = new Aggregations(new ArrayList()); List<Suggest.Suggestion<? extends Suggest.Suggestion.Entry<? extends Suggest.Suggestion.Entry.Option>>> suggestions = new ArrayList(); suggestions.add(new Suggest.Suggestion("sug1", 1)); suggestions.add(new Suggest.Suggestion("sug2", 2)); suggestions.add(new Suggest.Suggestion("sug3", 3)); suggestions.add(new Suggest.Suggestion("sug4", 4)); suggestions.add(new Suggest.Suggestion("sug5", 50)); Suggest suggest = new Suggest(suggestions); SearchProfileShardResults profileResults = new SearchProfileShardResults(Collections.emptyMap()); SearchResponseSections internalResponse = new SearchResponseSections(hits, aggregations, suggest, false, false, profileResults, 0); ShardSearchFailure[] shardFailures = new ShardSearchFailure[0]; SearchResponse.Clusters clusters = SearchResponse.Clusters.EMPTY; SearchResponse sRes = new SearchResponse(internalResponse, "id1", 1, 1, 1, 1, shardFailures, clusters); JSONObject res = QueryUtil.extractAggregationValue(sRes); assertNotNull(res.get("suggest")); assertNotNull(res.get("hits")); }
Example #2
Source File: LegacyDetectorRepositoryImplTest.java From adaptive-alerting with Apache License 2.0 | 5 votes |
@Test public void testFindByUuid_emptyResult() throws IOException { SearchHits hits = new SearchHits(new SearchHit[]{}, 0, 0); SearchResponseSections searchResponseSections = new SearchResponseSections(hits, null, null, false, null, null, 5); SearchResponse emptySearchResponse = new SearchResponse(searchResponseSections, "", 0, 0, 0, 0, null, null); Mockito.when(legacyElasticSearchClient.search(any(SearchRequest.class), any(RequestOptions.class))).thenReturn(emptySearchResponse); DetectorDocument actualDetector = repoUnderTest.findByUuid("missing-uuid"); assertNull(actualDetector); }
Example #3
Source File: KibanaUtilsTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
private void givenSearchResultToIncludePattern(String indexPattern) { SearchHit[] hits = new SearchHit[1]; hits[0] = new SearchHit(1, indexPattern, null, null); int totHits = 1; if (indexPattern == null) { totHits = 0; } SearchHits searchHits = new SearchHits(hits, totHits, 1.0f); SearchResponseSections sections = new SearchResponseSections(searchHits, null, null, false, Boolean.FALSE, null, 0); ShardSearchFailure[] failures = null; SearchResponse response = new SearchResponse(sections, "", 0, 0, 0, 0L, failures); when(client.search(anyString(), anyString(),anyInt(), anyBoolean())).thenReturn(response); }
Example #4
Source File: KibanaUtilsTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
public static void givenSearchResultForDocuments(PluginClient client, String indexPattern, Map<String, BytesReference> docs) { List<SearchHit> hits = new ArrayList<>(docs.size()); for (Map.Entry<String, BytesReference> entry : docs.entrySet()) { SearchHit hit = new SearchHit(1, entry.getKey(), null, null); hit.sourceRef(entry.getValue()); hits.add(hit); } SearchHits searchHits = new SearchHits(hits.toArray(new SearchHit[hits.size()]), hits.size(), 1.0f); SearchResponseSections sections = new SearchResponseSections(searchHits, null, null, false, Boolean.FALSE, null, 0); ShardSearchFailure[] failures = null; SearchResponse response = new SearchResponse(sections, "", 0, 0, 0, 0L, failures); when(client.search(anyString(), anyString(),anyInt(), anyBoolean())).thenReturn(response); }