@Test public void shouldReturnNull() throws Exception { EsRequest doc1 = client.getDocument(INDEX_NAME, TYPE_NAME, "1"); assertTrue(doc1 == null); }
public EsRequest getDocument(String name, String type, String id) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet(String.format("http: try { CloseableHttpResponse resp = client.execute(method); int status = resp.getStatusLine().getStatusCode(); switch (status) { case HttpStatus.SC_OK : EsResponse doc = EsResponse.read(resp.getEntity().getContent()); return new EsRequest((Document) doc.get("_source")); case HttpStatus.SC_NOT_ACCEPTABLE: case HttpStatus.SC_NOT_FOUND: return null; default: throw new IOException(resp.getStatusLine().getReasonPhrase()); } } finally { method.releaseConnection(); } }
EsClient { public EsRequest getDocument(String name, String type, String id) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet(String.format("http: try { CloseableHttpResponse resp = client.execute(method); int status = resp.getStatusLine().getStatusCode(); switch (status) { case HttpStatus.SC_OK : EsResponse doc = EsResponse.read(resp.getEntity().getContent()); return new EsRequest((Document) doc.get("_source")); case HttpStatus.SC_NOT_ACCEPTABLE: case HttpStatus.SC_NOT_FOUND: return null; default: throw new IOException(resp.getStatusLine().getReasonPhrase()); } } finally { method.releaseConnection(); } } }
EsClient { public EsRequest getDocument(String name, String type, String id) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet(String.format("http: try { CloseableHttpResponse resp = client.execute(method); int status = resp.getStatusLine().getStatusCode(); switch (status) { case HttpStatus.SC_OK : EsResponse doc = EsResponse.read(resp.getEntity().getContent()); return new EsRequest((Document) doc.get("_source")); case HttpStatus.SC_NOT_ACCEPTABLE: case HttpStatus.SC_NOT_FOUND: return null; default: throw new IOException(resp.getStatusLine().getReasonPhrase()); } } finally { method.releaseConnection(); } } EsClient(String host, int port); }
EsClient { public EsRequest getDocument(String name, String type, String id) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet(String.format("http: try { CloseableHttpResponse resp = client.execute(method); int status = resp.getStatusLine().getStatusCode(); switch (status) { case HttpStatus.SC_OK : EsResponse doc = EsResponse.read(resp.getEntity().getContent()); return new EsRequest((Document) doc.get("_source")); case HttpStatus.SC_NOT_ACCEPTABLE: case HttpStatus.SC_NOT_FOUND: return null; default: throw new IOException(resp.getStatusLine().getReasonPhrase()); } } finally { method.releaseConnection(); } } EsClient(String host, int port); boolean indexExists(String name); boolean createIndex(String name, String type, EsRequest mappings); boolean deleteIndex(String name); boolean storeDocument(String name, String type, String id,
            EsRequest doc); EsRequest getDocument(String name, String type, String id); boolean deleteDocument(String name, String type, String id); void deleteAll(String name, String type); void flush(String name); void refresh(String name); EsResponse search(String name, String type, EsRequest query); long count(String name, String type); }
EsClient { public EsRequest getDocument(String name, String type, String id) throws IOException { CloseableHttpClient client = HttpClients.createDefault(); HttpGet method = new HttpGet(String.format("http: try { CloseableHttpResponse resp = client.execute(method); int status = resp.getStatusLine().getStatusCode(); switch (status) { case HttpStatus.SC_OK : EsResponse doc = EsResponse.read(resp.getEntity().getContent()); return new EsRequest((Document) doc.get("_source")); case HttpStatus.SC_NOT_ACCEPTABLE: case HttpStatus.SC_NOT_FOUND: return null; default: throw new IOException(resp.getStatusLine().getReasonPhrase()); } } finally { method.releaseConnection(); } } EsClient(String host, int port); boolean indexExists(String name); boolean createIndex(String name, String type, EsRequest mappings); boolean deleteIndex(String name); boolean storeDocument(String name, String type, String id,
            EsRequest doc); EsRequest getDocument(String name, String type, String id); boolean deleteDocument(String name, String type, String id); void deleteAll(String name, String type); void flush(String name); void refresh(String name); EsResponse search(String name, String type, EsRequest query); long count(String name, String type);  }