Java Code Examples for org.elasticsearch.action.get.GetRequest#realtime()
The following examples show how to use
org.elasticsearch.action.get.GetRequest#realtime() .
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: RestHeadAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); getRequest.operationThreaded(true); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing getRequest.parent(request.param("parent")); getRequest.preference(request.param("preference")); getRequest.realtime(request.paramAsBoolean("realtime", null)); // don't get any fields back... getRequest.fields(Strings.EMPTY_ARRAY); // TODO we can also just return the document size as Content-Length client.get(getRequest, new RestResponseListener<GetResponse>(channel) { @Override public RestResponse buildResponse(GetResponse response) { if (!response.isExists()) { return new BytesRestResponse(NOT_FOUND); } else { return new BytesRestResponse(OK); } } }); }
Example 2
Source File: RestPercolateAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
void parseExistingDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) { String index = restRequest.param("index"); String type = restRequest.param("type"); percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("percolate_index", index))); percolateRequest.documentType(restRequest.param("percolate_type", type)); GetRequest getRequest = new GetRequest(index, type, restRequest.param("id")); getRequest.routing(restRequest.param("routing")); getRequest.preference(restRequest.param("preference")); getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh())); getRequest.realtime(restRequest.paramAsBoolean("realtime", null)); getRequest.version(RestActions.parseVersion(restRequest)); getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType())); percolateRequest.getRequest(getRequest); percolateRequest.routing(restRequest.param("percolate_routing")); percolateRequest.preference(restRequest.param("percolate_preference")); percolateRequest.source(RestActions.getRestContent(restRequest)); percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions())); executePercolate(percolateRequest, restChannel, client); }
Example 3
Source File: RestGetAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); getRequest.operationThreaded(true); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing getRequest.parent(request.param("parent")); getRequest.preference(request.param("preference")); getRequest.realtime(request.paramAsBoolean("realtime", null)); getRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false)); String sField = request.param("fields"); if (sField != null) { String[] sFields = Strings.splitStringByCommaToArray(sField); if (sFields != null) { getRequest.fields(sFields); } } getRequest.version(RestActions.parseVersion(request)); getRequest.versionType(VersionType.fromString(request.param("version_type"), getRequest.versionType())); getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request)); client.get(getRequest, new RestBuilderListener<GetResponse>(channel) { @Override public RestResponse buildResponse(GetResponse response, XContentBuilder builder) throws Exception { builder.startObject(); response.toXContent(builder, request); builder.endObject(); if (!response.isExists()) { return new BytesRestResponse(NOT_FOUND, builder); } else { return new BytesRestResponse(OK, builder); } } }); }
Example 4
Source File: RestGetSourceAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); getRequest.operationThreaded(true); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing getRequest.parent(request.param("parent")); getRequest.preference(request.param("preference")); getRequest.realtime(request.paramAsBoolean("realtime", null)); getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request)); if (getRequest.fetchSourceContext() != null && !getRequest.fetchSourceContext().fetchSource()) { try { ActionRequestValidationException validationError = new ActionRequestValidationException(); validationError.addValidationError("fetching source can not be disabled"); channel.sendResponse(new BytesRestResponse(channel, validationError)); } catch (IOException e) { logger.error("Failed to send failure response", e); } } client.get(getRequest, new RestResponseListener<GetResponse>(channel) { @Override public RestResponse buildResponse(GetResponse response) throws Exception { XContentBuilder builder = channel.newBuilder(response.getSourceInternal(), false); if (!response.isExists()) { return new BytesRestResponse(NOT_FOUND, builder); } else { builder.rawValue(response.getSourceInternal()); return new BytesRestResponse(OK, builder); } } }); }
Example 5
Source File: InternalEsClient.java From io with Apache License 2.0 | 5 votes |
/** * 非同期でドキュメントを取得. * @param index インデックス名 * @param type タイプ名 * @param id ドキュメントのID * @param routingId routingId * @param realtime リアルタイムモードなら真 * @return 非同期応答 */ public ActionFuture<GetResponse> asyncGet(String index, String type, String id, String routingId, boolean realtime) { GetRequest req = new GetRequest(index, type, id); if (routingFlag) { req = req.routing(routingId); } req.realtime(realtime); ActionFuture<GetResponse> ret = esTransportClient.get(req); this.fireEvent(Event.afterRequest, index, type, id, null, "Get"); return ret; }
Example 6
Source File: InternalEsClient.java From io with Apache License 2.0 | 5 votes |
/** * 非同期でドキュメントを取得. * @param index インデックス名 * @param type タイプ名 * @param id ドキュメントのID * @param routingId routingId * @param realtime リアルタイムモードなら真 * @return 非同期応答 */ public ActionFuture<GetResponse> asyncGet(String index, String type, String id, String routingId, boolean realtime) { GetRequest req = new GetRequest(index, type, id); if (routingFlag) { req = req.routing(routingId); } req.realtime(realtime); ActionFuture<GetResponse> ret = esTransportClient.get(req); this.fireEvent(Event.afterRequest, index, type, id, null, "Get"); return ret; }