@SuppressWarnings("deprecation") @Test public void getDataFromESBySizeTest() throws Exception { final ElasticSearchRepository classUnderTest = PowerMockito.spy(new ElasticSearchRepository()); ReflectionTestUtils.setField(classUnderTest, "esUrl", "esUrl123"); mockStatic(StringBuilder.class); mockStatic(PacHttpUtils.class); String response = "{\"count\":\"123\", \"hits\":{\"total\":1000,\"max_score\":null,\"hits\":[{\"_index\":\"bank\",\"_type\":\"_doc\",\"_id\":\"0\",\"sort\":[0],\"_score\":null,\"_source\":{\"account_number\":0,\"balance\":16623,\"firstname\":\"Bradshaw\",\"lastname\":\"Mckenzie\",\"age\":29,\"gender\":\"F\",\"address\":\"244 Columbus Place\",\"employer\":\"Euron\",\"email\":\"bradshawmckenzie@euron.com\",\"city\":\"Hobucken\",\"state\":\"CO\"}}]},\"aggregations\":{\"name\":{\"buckets\":[{\"key\":\"ID\",\"doc_count\":27},{\"key\":\"TX\",\"doc_count\":27}]}}}"; PowerMockito.when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenReturn(response); assertThat(classUnderTest.getDataFromESBySize(eq("dataSource"), eq("targetType"), anyObject(), anyObject(), anyObject(), anyObject(), eq(1), eq(1), anyObject(), anyObject()).size(), is(1)); }
@Deprecated public List<Map<String, Object>> getDataFromESBySize(String dataSource, String targetType, final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter, final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText, final Map<String, Object> mustTermsFilter) throws Exception { if (size <= 0) { size = (int) getTotalDocumentCountForIndexAndType(dataSource, targetType, mustFilter, mustNotFilter, null, searchText, mustTermsFilter); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append(FORWARD_SLASH).append(dataSource); if (!Strings.isNullOrEmpty(targetType)) { urlToQueryBuffer.append(FORWARD_SLASH).append(targetType); } urlToQueryBuffer.append(FORWARD_SLASH).append(_SEARCH); String urlToQuery = urlToQueryBuffer.toString(); Map<String, Object> requestBody = new HashMap<String, Object>(); requestBody.put(SIZE, ES_PAGE_SIZE); if ((from + size) < ES_PAGE_SIZE) { requestBody.put(SIZE, (from + size)); } requestBody.put(QUERY, buildQuery(mustFilter, mustNotFilter, shouldFilter, searchText, mustTermsFilter,null)); requestBody.put(_SOURCE, fields); Gson serializer = new GsonBuilder().create(); String request = serializer.toJson(requestBody); return prepareResultsUsingScroll(from, size, urlToQuery, request); }
ElasticSearchRepository implements Constants { @Deprecated public List<Map<String, Object>> getDataFromESBySize(String dataSource, String targetType, final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter, final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText, final Map<String, Object> mustTermsFilter) throws Exception { if (size <= 0) { size = (int) getTotalDocumentCountForIndexAndType(dataSource, targetType, mustFilter, mustNotFilter, null, searchText, mustTermsFilter); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append(FORWARD_SLASH).append(dataSource); if (!Strings.isNullOrEmpty(targetType)) { urlToQueryBuffer.append(FORWARD_SLASH).append(targetType); } urlToQueryBuffer.append(FORWARD_SLASH).append(_SEARCH); String urlToQuery = urlToQueryBuffer.toString(); Map<String, Object> requestBody = new HashMap<String, Object>(); requestBody.put(SIZE, ES_PAGE_SIZE); if ((from + size) < ES_PAGE_SIZE) { requestBody.put(SIZE, (from + size)); } requestBody.put(QUERY, buildQuery(mustFilter, mustNotFilter, shouldFilter, searchText, mustTermsFilter,null)); requestBody.put(_SOURCE, fields); Gson serializer = new GsonBuilder().create(); String request = serializer.toJson(requestBody); return prepareResultsUsingScroll(from, size, urlToQuery, request); } }
ElasticSearchRepository implements Constants { @Deprecated public List<Map<String, Object>> getDataFromESBySize(String dataSource, String targetType, final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter, final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText, final Map<String, Object> mustTermsFilter) throws Exception { if (size <= 0) { size = (int) getTotalDocumentCountForIndexAndType(dataSource, targetType, mustFilter, mustNotFilter, null, searchText, mustTermsFilter); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append(FORWARD_SLASH).append(dataSource); if (!Strings.isNullOrEmpty(targetType)) { urlToQueryBuffer.append(FORWARD_SLASH).append(targetType); } urlToQueryBuffer.append(FORWARD_SLASH).append(_SEARCH); String urlToQuery = urlToQueryBuffer.toString(); Map<String, Object> requestBody = new HashMap<String, Object>(); requestBody.put(SIZE, ES_PAGE_SIZE); if ((from + size) < ES_PAGE_SIZE) { requestBody.put(SIZE, (from + size)); } requestBody.put(QUERY, buildQuery(mustFilter, mustNotFilter, shouldFilter, searchText, mustTermsFilter,null)); requestBody.put(_SOURCE, fields); Gson serializer = new GsonBuilder().create(); String request = serializer.toJson(requestBody); return prepareResultsUsingScroll(from, size, urlToQuery, request); }  }
ElasticSearchRepository implements Constants { @Deprecated public List<Map<String, Object>> getDataFromESBySize(String dataSource, String targetType, final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter, final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText, final Map<String, Object> mustTermsFilter) throws Exception { if (size <= 0) { size = (int) getTotalDocumentCountForIndexAndType(dataSource, targetType, mustFilter, mustNotFilter, null, searchText, mustTermsFilter); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append(FORWARD_SLASH).append(dataSource); if (!Strings.isNullOrEmpty(targetType)) { urlToQueryBuffer.append(FORWARD_SLASH).append(targetType); } urlToQueryBuffer.append(FORWARD_SLASH).append(_SEARCH); String urlToQuery = urlToQueryBuffer.toString(); Map<String, Object> requestBody = new HashMap<String, Object>(); requestBody.put(SIZE, ES_PAGE_SIZE); if ((from + size) < ES_PAGE_SIZE) { requestBody.put(SIZE, (from + size)); } requestBody.put(QUERY, buildQuery(mustFilter, mustNotFilter, shouldFilter, searchText, mustTermsFilter,null)); requestBody.put(_SOURCE, fields); Gson serializer = new GsonBuilder().create(); String request = serializer.toJson(requestBody); return prepareResultsUsingScroll(from, size, urlToQuery, request); }  @SuppressWarnings("unchecked") @Deprecated List<Map<String, Object>> getDataFromES(String dataSource, String targetType, Map<String, Object> mustFilter,
			final Map<String, Object> mustNotFilter, final HashMultimap<String, Object> shouldFilter,
			List<String> fields, Map<String, Object> mustTermsFilter); @SuppressWarnings("unchecked") List<Map<String, Object>> getSortedDataFromES(String dataSource, String targetType,
			Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, Map<String, Object> mustTermsFilter,
			List<Map<String, Object>> sortFieldMapList); Map<String, Object> buildAggs(String distributionName, int size, String aggsName, Map<String, Object> nestedAggs); Map<String, Object> buildQuery(final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, final String searchText,
			final Map<String, Object> mustTermsFilter,Map<String, List<String>> matchPhrasePrefix); String buildScrollRequest(String scrollId, String esPageScrollTtl); String processResponseAndSendTheScrollBack(String responseDetails, List<Map<String, Object>> results); @SuppressWarnings("unchecked") long getTotalDocumentCountForIndexAndType(String index, String type, Map<String, Object> mustFilter,
			Map<String, Object> mustNotFilter, HashMultimap<String, Object> shouldFilter, String searchText,
			Map<String, Object> mustTermsFilter); Map<String, Long> getTotalDistributionForIndexAndType(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String aggsFilter, int size, Map<String, Object> mustTermsFilter); String buildAggsURL(String url, String index, String type); List<Map<String, Object>> getUtilizationByAssetGroup(String asseGroup); @Deprecated List<Map<String, Object>> getDataFromESBySize(String dataSource, String targetType,
			final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText,
			final Map<String, Object> mustTermsFilter); List<Map<String, Object>> getSortedDataFromESBySize(String dataSource, String targetType,
			final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText,
			final Map<String, Object> mustTermsFilter, List<Map<String, Object>> sortFieldMapList); @SuppressWarnings("unchecked") Boolean updatePartialDataToES(String dataSource, String targetType, String id, String routing, String parent,
			Map<String, Object> partialDocument); @SuppressWarnings("unchecked") Boolean saveExceptionDataToES(String dataSource, String routing, Map<String, Object> data); Map<String, Long> getTotalDistributionForIndexAndTypeBySize(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String aggsFilter, int size, int from, String searchText); Map<String, Long> getDateHistogramForIndexAndTypeByInterval(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String dateFieldName, String interval); Map<String, String> getAccountsByMultiAggs(String index, String type, Map<String, Object> filter,
			Map<String, Object> mustNotFilter, HashMultimap<String, Object> shouldFilter,
			Map<String, Object> aggsFilter, int size); List<LinkedHashMap<String, Object>> getDetailsFromESBySize(String dataSource, String targetType,
			final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText,
			final Map<String, Object> mustTermsFilter); @SuppressWarnings("unchecked") @Deprecated List<Map<String, Object>> getDataFromESWithMustNotTermsFilter(String dataSource, String targetType,
			Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, Map<String, Object> mustTermsFilter,
			Map<String, Object> mustNotTermsFilter, Map<String, Object> mustNotWildCardFilter); @SuppressWarnings("unchecked") List<Map<String, Object>> getSortedDataFromESWithMustNotTermsFilter(String dataSource, String targetType,
			Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, Map<String, Object> mustTermsFilter,
			Map<String, Object> mustNotTermsFilter, Map<String, Object> mustNotWildCardFilter,
			List<Map<String, Object>> sortFieldMapList); long getTotalDocumentCountForIndexAndTypeWithMustNotTermsFilter(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String searchText, Map<String, Object> mustTermsFilter,
			Map<String, Object> mustNotTermsFilter, Map<String, Object> mustNotWildCardFilter); @SuppressWarnings("unchecked") long getTotalDistributionForIndexAndTypeWithMatchPhrase(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String searchText,
			Map<String, Object> mustTermsFilter,
			Map<String, List<String>> matchPhrasePrefix); String buildESURL(String url, String index, String type, int size, int from); Map<String, Object> getEnvAndTotalDistributionForIndexAndType(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String aggsFilter, Map<String, Object> nestedaggs, int size, Map<String, Object> mustTermsFilter); }
ElasticSearchRepository implements Constants { @Deprecated public List<Map<String, Object>> getDataFromESBySize(String dataSource, String targetType, final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter, final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText, final Map<String, Object> mustTermsFilter) throws Exception { if (size <= 0) { size = (int) getTotalDocumentCountForIndexAndType(dataSource, targetType, mustFilter, mustNotFilter, null, searchText, mustTermsFilter); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append(FORWARD_SLASH).append(dataSource); if (!Strings.isNullOrEmpty(targetType)) { urlToQueryBuffer.append(FORWARD_SLASH).append(targetType); } urlToQueryBuffer.append(FORWARD_SLASH).append(_SEARCH); String urlToQuery = urlToQueryBuffer.toString(); Map<String, Object> requestBody = new HashMap<String, Object>(); requestBody.put(SIZE, ES_PAGE_SIZE); if ((from + size) < ES_PAGE_SIZE) { requestBody.put(SIZE, (from + size)); } requestBody.put(QUERY, buildQuery(mustFilter, mustNotFilter, shouldFilter, searchText, mustTermsFilter,null)); requestBody.put(_SOURCE, fields); Gson serializer = new GsonBuilder().create(); String request = serializer.toJson(requestBody); return prepareResultsUsingScroll(from, size, urlToQuery, request); }  @SuppressWarnings("unchecked") @Deprecated List<Map<String, Object>> getDataFromES(String dataSource, String targetType, Map<String, Object> mustFilter,
			final Map<String, Object> mustNotFilter, final HashMultimap<String, Object> shouldFilter,
			List<String> fields, Map<String, Object> mustTermsFilter); @SuppressWarnings("unchecked") List<Map<String, Object>> getSortedDataFromES(String dataSource, String targetType,
			Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, Map<String, Object> mustTermsFilter,
			List<Map<String, Object>> sortFieldMapList); Map<String, Object> buildAggs(String distributionName, int size, String aggsName, Map<String, Object> nestedAggs); Map<String, Object> buildQuery(final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, final String searchText,
			final Map<String, Object> mustTermsFilter,Map<String, List<String>> matchPhrasePrefix); String buildScrollRequest(String scrollId, String esPageScrollTtl); String processResponseAndSendTheScrollBack(String responseDetails, List<Map<String, Object>> results); @SuppressWarnings("unchecked") long getTotalDocumentCountForIndexAndType(String index, String type, Map<String, Object> mustFilter,
			Map<String, Object> mustNotFilter, HashMultimap<String, Object> shouldFilter, String searchText,
			Map<String, Object> mustTermsFilter); Map<String, Long> getTotalDistributionForIndexAndType(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String aggsFilter, int size, Map<String, Object> mustTermsFilter); String buildAggsURL(String url, String index, String type); List<Map<String, Object>> getUtilizationByAssetGroup(String asseGroup); @Deprecated List<Map<String, Object>> getDataFromESBySize(String dataSource, String targetType,
			final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText,
			final Map<String, Object> mustTermsFilter); List<Map<String, Object>> getSortedDataFromESBySize(String dataSource, String targetType,
			final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText,
			final Map<String, Object> mustTermsFilter, List<Map<String, Object>> sortFieldMapList); @SuppressWarnings("unchecked") Boolean updatePartialDataToES(String dataSource, String targetType, String id, String routing, String parent,
			Map<String, Object> partialDocument); @SuppressWarnings("unchecked") Boolean saveExceptionDataToES(String dataSource, String routing, Map<String, Object> data); Map<String, Long> getTotalDistributionForIndexAndTypeBySize(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String aggsFilter, int size, int from, String searchText); Map<String, Long> getDateHistogramForIndexAndTypeByInterval(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String dateFieldName, String interval); Map<String, String> getAccountsByMultiAggs(String index, String type, Map<String, Object> filter,
			Map<String, Object> mustNotFilter, HashMultimap<String, Object> shouldFilter,
			Map<String, Object> aggsFilter, int size); List<LinkedHashMap<String, Object>> getDetailsFromESBySize(String dataSource, String targetType,
			final Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, int from, int size, String searchText,
			final Map<String, Object> mustTermsFilter); @SuppressWarnings("unchecked") @Deprecated List<Map<String, Object>> getDataFromESWithMustNotTermsFilter(String dataSource, String targetType,
			Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, Map<String, Object> mustTermsFilter,
			Map<String, Object> mustNotTermsFilter, Map<String, Object> mustNotWildCardFilter); @SuppressWarnings("unchecked") List<Map<String, Object>> getSortedDataFromESWithMustNotTermsFilter(String dataSource, String targetType,
			Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
			final HashMultimap<String, Object> shouldFilter, List<String> fields, Map<String, Object> mustTermsFilter,
			Map<String, Object> mustNotTermsFilter, Map<String, Object> mustNotWildCardFilter,
			List<Map<String, Object>> sortFieldMapList); long getTotalDocumentCountForIndexAndTypeWithMustNotTermsFilter(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String searchText, Map<String, Object> mustTermsFilter,
			Map<String, Object> mustNotTermsFilter, Map<String, Object> mustNotWildCardFilter); @SuppressWarnings("unchecked") long getTotalDistributionForIndexAndTypeWithMatchPhrase(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String searchText,
			Map<String, Object> mustTermsFilter,
			Map<String, List<String>> matchPhrasePrefix); String buildESURL(String url, String index, String type, int size, int from); Map<String, Object> getEnvAndTotalDistributionForIndexAndType(String index, String type,
			Map<String, Object> mustFilter, Map<String, Object> mustNotFilter,
			HashMultimap<String, Object> shouldFilter, String aggsFilter, Map<String, Object> nestedaggs, int size, Map<String, Object> mustTermsFilter);  }