public boolean delete(String indexOrType) { Request req = new SimpleRequest(DELETE, null, indexOrType); Response res = executeNotFoundAllowed(req); return (res.status() == HttpStatus.OK ? true : false); } public boolean deleteScroll(String scrollId) {
public boolean isEmpty(boolean read) { Resource res = (read ? resources.getResourceRead() : resources.getResourceWrite()); boolean exists = client.indexExists(res.index()); return (exists ? count(read) <= 0 : true); }
@Override public boolean hasNext() { ScrollQuery sq = getCurrent(); return (sq != null ? sq.hasNext() : false); }
public long count(boolean read) { Resource res = (read ? resources.getResourceRead() : resources.getResourceWrite()); if (res.isTyped()) { return client.count(res.index(), res.type(), QueryUtils.parseQuery(settings)); } else { return client.count(res.index(), QueryUtils.parseQuery(settings)); } }
protected Response execute(Method method, String path, boolean checkStatus) { return execute(new SimpleRequest(method, null, path), checkStatus); }
@Override public void close() { if (finished) { return; } ScrollQuery sq = getCurrent(); if (sq != null) { sq.close(); } if (currentReader != null) { currentReader.close(); } finished = true; }
protected Response executeNotFoundAllowed(Request req) { Response res = execute(req, false); switch (res.status()) { case HttpStatus.OK: break; case HttpStatus.NOT_FOUND: break; default: checkResponse(req, res); } return res; }
public boolean touch() { return client.touch(resources.getResourceWrite().index()); }
public MappingSet getMappings(Resource indexResource) { if (indexResource.isTyped()) { return getMappings(indexResource.index() + "/_mapping/" + indexResource.type(), true); } else { return getMappings(indexResource.index() + "/_mapping", false); } }
public ScrollQuery build(RestRepository client, ScrollReader reader) { String scrollUri = assemble(); BytesArray requestBody = assembleBody(); return client.scanLimit(scrollUri, requestBody, limit, reader); }
@Override public Object[] next() { ScrollQuery sq = getCurrent(); return sq.next(); }
protected Response execute(Request request, boolean checkStatus) { Response response = network.execute(request); if (checkStatus) { checkResponse(request, response); } return response; }
protected Response execute(Method method, String path, ByteSequence buffer) { return execute(new SimpleRequest(method, null, path, null, buffer), true); }
private boolean exists(String indexOrType) { Request req = new SimpleRequest(HEAD, null, indexOrType); Response res = executeNotFoundAllowed(req); return (res.status() == HttpStatus.OK ? true : false); }
protected Response execute(Method method, String path, ByteSequence buffer, boolean checkStatus) { return execute(new SimpleRequest(method, null, path, null, buffer), checkStatus); }
protected Response execute(Method method, String path, String params, ByteSequence buffer, boolean checkStatus) { return execute(new SimpleRequest(method, null, path, params, buffer), checkStatus); }
protected InputStream execute(Method method, String path) { return execute(new SimpleRequest(method, null, path)); }