@Test public void parseFoundTwoAndOneNotFound() { Map<String,String> parsedDoc = ElasticSearchRelatedItemHttpGetRepository.processResults(FOUND_TWO_ONE_NOT_FOUND); assertTrue(parsedDoc.size()==2); assertTrue(parsedDoc.containsKey("1")); assertTrue(parsedDoc.containsKey("2")); assertTrue(parsedDoc.get("1").contains("a8f346c5ddbbd8d438bc40f0049cc7f8")); assertTrue(parsedDoc.get("2").contains("71a5120bdf4d998c2b043a681b1bd211")); }
public static Map<String,String> processResults(String responseBody) { JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627); try { JSONObject object = (JSONObject)parser.parse(responseBody); Object results = object.get("docs"); if(results!=null && results instanceof JSONArray) { return parseDocs((JSONArray)results); }else { return Collections.EMPTY_MAP; } } catch (Exception e){ return Collections.EMPTY_MAP; } }
ElasticSearchRelatedItemHttpGetRepository implements RelatedItemGetRepository { public static Map<String,String> processResults(String responseBody) { JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627); try { JSONObject object = (JSONObject)parser.parse(responseBody); Object results = object.get("docs"); if(results!=null && results instanceof JSONArray) { return parseDocs((JSONArray)results); }else { return Collections.EMPTY_MAP; } } catch (Exception e){ return Collections.EMPTY_MAP; } } }
ElasticSearchRelatedItemHttpGetRepository implements RelatedItemGetRepository { public static Map<String,String> processResults(String responseBody) { JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627); try { JSONObject object = (JSONObject)parser.parse(responseBody); Object results = object.get("docs"); if(results!=null && results instanceof JSONArray) { return parseDocs((JSONArray)results); }else { return Collections.EMPTY_MAP; } } catch (Exception e){ return Collections.EMPTY_MAP; } } ElasticSearchRelatedItemHttpGetRepository(Configuration configuration,
                                                     HttpElasticSearchClientFactory factory); }
ElasticSearchRelatedItemHttpGetRepository implements RelatedItemGetRepository { public static Map<String,String> processResults(String responseBody) { JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627); try { JSONObject object = (JSONObject)parser.parse(responseBody); Object results = object.get("docs"); if(results!=null && results instanceof JSONArray) { return parseDocs((JSONArray)results); }else { return Collections.EMPTY_MAP; } } catch (Exception e){ return Collections.EMPTY_MAP; } } ElasticSearchRelatedItemHttpGetRepository(Configuration configuration,
                                                     HttpElasticSearchClientFactory factory); @Override Map<String, String> getRelatedItemDocument(String[] ids); @Override void shutdown(); static Map<String,String> processResults(String responseBody); static Map<String,String> parseDocs(JSONArray array); }
ElasticSearchRelatedItemHttpGetRepository implements RelatedItemGetRepository { public static Map<String,String> processResults(String responseBody) { JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627); try { JSONObject object = (JSONObject)parser.parse(responseBody); Object results = object.get("docs"); if(results!=null && results instanceof JSONArray) { return parseDocs((JSONArray)results); }else { return Collections.EMPTY_MAP; } } catch (Exception e){ return Collections.EMPTY_MAP; } } ElasticSearchRelatedItemHttpGetRepository(Configuration configuration,
                                                     HttpElasticSearchClientFactory factory); @Override Map<String, String> getRelatedItemDocument(String[] ids); @Override void shutdown(); static Map<String,String> processResults(String responseBody); static Map<String,String> parseDocs(JSONArray array);  }