parent
4169b00441
commit
ba08313417
|
@ -26,10 +26,8 @@ package org.elasticsearch.action;
|
|||
public interface RealtimeRequest {
|
||||
|
||||
/**
|
||||
* @param realtime Controls whether this request should be realtime by reading from the translog. If <code>null</code>
|
||||
* is specified then whether the operation will be realtime depends on the api of the concrete request
|
||||
* subclass.
|
||||
* @param realtime Controls whether this request should be realtime by reading from the translog.
|
||||
*/
|
||||
<R extends RealtimeRequest> R realtime(Boolean realtime);
|
||||
<R extends RealtimeRequest> R realtime(boolean realtime);
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
|
|||
|
||||
private boolean refresh = false;
|
||||
|
||||
Boolean realtime;
|
||||
boolean realtime = true;
|
||||
|
||||
private VersionType versionType = VersionType.INTERNAL;
|
||||
private long version = Versions.MATCH_ANY;
|
||||
|
@ -218,11 +218,11 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
|
|||
}
|
||||
|
||||
public boolean realtime() {
|
||||
return this.realtime == null ? true : this.realtime;
|
||||
return this.realtime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetRequest realtime(Boolean realtime) {
|
||||
public GetRequest realtime(boolean realtime) {
|
||||
this.realtime = realtime;
|
||||
return this;
|
||||
}
|
||||
|
@ -277,12 +277,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
|
|||
fields[i] = in.readString();
|
||||
}
|
||||
}
|
||||
byte realtime = in.readByte();
|
||||
if (realtime == 0) {
|
||||
this.realtime = false;
|
||||
} else if (realtime == 1) {
|
||||
this.realtime = true;
|
||||
}
|
||||
realtime = in.readBoolean();
|
||||
this.ignoreErrorsOnGeneratedFields = in.readBoolean();
|
||||
|
||||
this.versionType = VersionType.fromValue(in.readByte());
|
||||
|
@ -308,13 +303,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
|
|||
out.writeString(field);
|
||||
}
|
||||
}
|
||||
if (realtime == null) {
|
||||
out.writeByte((byte) -1);
|
||||
} else if (!realtime) {
|
||||
out.writeByte((byte) 0);
|
||||
} else {
|
||||
out.writeByte((byte) 1);
|
||||
}
|
||||
out.writeBoolean(realtime);
|
||||
out.writeBoolean(ignoreErrorsOnGeneratedFields);
|
||||
out.writeByte(versionType.getValue());
|
||||
out.writeLong(version);
|
||||
|
|
|
@ -150,7 +150,7 @@ public class GetRequestBuilder extends SingleShardOperationRequestBuilder<GetReq
|
|||
return this;
|
||||
}
|
||||
|
||||
public GetRequestBuilder setRealtime(Boolean realtime) {
|
||||
public GetRequestBuilder setRealtime(boolean realtime) {
|
||||
request.realtime(realtime);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
|
|||
}
|
||||
|
||||
String preference;
|
||||
Boolean realtime;
|
||||
boolean realtime = true;
|
||||
boolean refresh;
|
||||
public boolean ignoreErrorsOnGeneratedFields = false;
|
||||
|
||||
|
@ -319,11 +319,11 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
|
|||
}
|
||||
|
||||
public boolean realtime() {
|
||||
return this.realtime == null ? true : this.realtime;
|
||||
return this.realtime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiGetRequest realtime(Boolean realtime) {
|
||||
public MultiGetRequest realtime(boolean realtime) {
|
||||
this.realtime = realtime;
|
||||
return this;
|
||||
}
|
||||
|
@ -509,12 +509,7 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
|
|||
super.readFrom(in);
|
||||
preference = in.readOptionalString();
|
||||
refresh = in.readBoolean();
|
||||
byte realtime = in.readByte();
|
||||
if (realtime == 0) {
|
||||
this.realtime = false;
|
||||
} else if (realtime == 1) {
|
||||
this.realtime = true;
|
||||
}
|
||||
realtime = in.readBoolean();
|
||||
ignoreErrorsOnGeneratedFields = in.readBoolean();
|
||||
|
||||
int size = in.readVInt();
|
||||
|
@ -529,13 +524,7 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
|
|||
super.writeTo(out);
|
||||
out.writeOptionalString(preference);
|
||||
out.writeBoolean(refresh);
|
||||
if (realtime == null) {
|
||||
out.writeByte((byte) -1);
|
||||
} else if (realtime == false) {
|
||||
out.writeByte((byte) 0);
|
||||
} else {
|
||||
out.writeByte((byte) 1);
|
||||
}
|
||||
out.writeBoolean(realtime);
|
||||
out.writeBoolean(ignoreErrorsOnGeneratedFields);
|
||||
|
||||
out.writeVInt(items.size());
|
||||
|
|
|
@ -76,7 +76,7 @@ public class MultiGetRequestBuilder extends ActionRequestBuilder<MultiGetRequest
|
|||
return this;
|
||||
}
|
||||
|
||||
public MultiGetRequestBuilder setRealtime(Boolean realtime) {
|
||||
public MultiGetRequestBuilder setRealtime(boolean realtime) {
|
||||
request.realtime(realtime);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
|
|||
|
||||
private int shardId;
|
||||
private String preference;
|
||||
Boolean realtime;
|
||||
boolean realtime = true;
|
||||
boolean refresh;
|
||||
boolean ignoreErrorsOnGeneratedFields = false;
|
||||
|
||||
|
@ -79,10 +79,10 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
|
|||
}
|
||||
|
||||
public boolean realtime() {
|
||||
return this.realtime == null ? true : this.realtime;
|
||||
return this.realtime;
|
||||
}
|
||||
|
||||
public MultiGetShardRequest realtime(Boolean realtime) {
|
||||
public MultiGetShardRequest realtime(boolean realtime) {
|
||||
this.realtime = realtime;
|
||||
return this;
|
||||
}
|
||||
|
@ -129,12 +129,7 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
|
|||
|
||||
preference = in.readOptionalString();
|
||||
refresh = in.readBoolean();
|
||||
byte realtime = in.readByte();
|
||||
if (realtime == 0) {
|
||||
this.realtime = false;
|
||||
} else if (realtime == 1) {
|
||||
this.realtime = true;
|
||||
}
|
||||
realtime = in.readBoolean();
|
||||
ignoreErrorsOnGeneratedFields = in.readBoolean();
|
||||
}
|
||||
|
||||
|
@ -150,13 +145,7 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
|
|||
|
||||
out.writeOptionalString(preference);
|
||||
out.writeBoolean(refresh);
|
||||
if (realtime == null) {
|
||||
out.writeByte((byte) -1);
|
||||
} else if (!realtime) {
|
||||
out.writeByte((byte) 0);
|
||||
} else {
|
||||
out.writeByte((byte) 1);
|
||||
}
|
||||
out.writeBoolean(realtime);
|
||||
out.writeBoolean(ignoreErrorsOnGeneratedFields);
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.elasticsearch.transport.TransportService;
|
|||
public class TransportGetAction extends TransportSingleShardAction<GetRequest, GetResponse> {
|
||||
|
||||
private final IndicesService indicesService;
|
||||
private final boolean realtime;
|
||||
|
||||
@Inject
|
||||
public TransportGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||
|
@ -53,8 +52,6 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
|
|||
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
GetRequest::new, ThreadPool.Names.GET);
|
||||
this.indicesService = indicesService;
|
||||
|
||||
this.realtime = settings.getAsBoolean("action.get.realtime", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,9 +67,6 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
|
|||
|
||||
@Override
|
||||
protected void resolveRequest(ClusterState state, InternalRequest request) {
|
||||
if (request.request().realtime == null) {
|
||||
request.request().realtime = this.realtime;
|
||||
}
|
||||
IndexMetaData indexMeta = state.getMetaData().index(request.concreteIndex());
|
||||
if (request.request().realtime && // if the realtime flag is set
|
||||
request.request().preference() == null && // the preference flag is not already set
|
||||
|
|
|
@ -43,8 +43,6 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
|||
|
||||
private final IndicesService indicesService;
|
||||
|
||||
private final boolean realtime;
|
||||
|
||||
@Inject
|
||||
public TransportShardMultiGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
|
@ -52,8 +50,6 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
|||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
MultiGetShardRequest::new, ThreadPool.Names.GET);
|
||||
this.indicesService = indicesService;
|
||||
|
||||
this.realtime = settings.getAsBoolean("action.get.realtime", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,13 +73,6 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
|||
.getShards(state, request.request().index(), request.request().shardId(), request.request().preference());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resolveRequest(ClusterState state, InternalRequest request) {
|
||||
if (request.request().realtime == null) {
|
||||
request.request().realtime = this.realtime;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MultiGetShardResponse shardOperation(MultiGetShardRequest request, ShardId shardId) {
|
||||
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
|
||||
|
|
|
@ -173,7 +173,7 @@ public class MultiTermVectorsRequest extends ActionRequest<MultiTermVectorsReque
|
|||
}
|
||||
|
||||
@Override
|
||||
public MultiTermVectorsRequest realtime(Boolean realtime) {
|
||||
public MultiTermVectorsRequest realtime(boolean realtime) {
|
||||
for (TermVectorsRequest request : requests) {
|
||||
request.realtime(realtime);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
|
|||
// TODO: change to String[]
|
||||
private Set<String> selectedFields;
|
||||
|
||||
Boolean realtime;
|
||||
private boolean realtime = true;
|
||||
|
||||
private Map<String, String> perFieldAnalyzer;
|
||||
|
||||
|
@ -394,14 +394,11 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
|
|||
* Return whether term vectors should be generated real-time (default to true).
|
||||
*/
|
||||
public boolean realtime() {
|
||||
return this.realtime == null ? true : this.realtime;
|
||||
return this.realtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose whether term vectors be generated real-time.
|
||||
*/
|
||||
@Override
|
||||
public TermVectorsRequest realtime(Boolean realtime) {
|
||||
public TermVectorsRequest realtime(boolean realtime) {
|
||||
this.realtime = realtime;
|
||||
return this;
|
||||
}
|
||||
|
@ -559,7 +556,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
|
|||
if (filterSettings != null) {
|
||||
filterSettings.writeTo(out);
|
||||
}
|
||||
out.writeBoolean(realtime());
|
||||
out.writeBoolean(realtime);
|
||||
out.writeByte(versionType.getValue());
|
||||
out.writeLong(version);
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class TermVectorsRequestBuilder extends ActionRequestBuilder<TermVectorsR
|
|||
/**
|
||||
* Sets whether term vectors are generated real-time.
|
||||
*/
|
||||
public TermVectorsRequestBuilder setRealtime(Boolean realtime) {
|
||||
public TermVectorsRequestBuilder setRealtime(boolean realtime) {
|
||||
request.realtime(realtime);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class RestGetAction extends BaseRestHandler {
|
|||
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.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));
|
||||
getRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));
|
||||
|
||||
String sField = request.param("fields");
|
||||
|
|
|
@ -60,7 +60,7 @@ public class RestGetSourceAction extends BaseRestHandler {
|
|||
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.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));
|
||||
|
||||
getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RestHeadAction extends BaseRestHandler {
|
|||
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.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));
|
||||
// don't get any fields back...
|
||||
getRequest.fields(Strings.EMPTY_ARRAY);
|
||||
// TODO we can also just return the document size as Content-Length
|
||||
|
|
|
@ -58,7 +58,7 @@ public class RestMultiGetAction extends BaseRestHandler {
|
|||
MultiGetRequest multiGetRequest = new MultiGetRequest();
|
||||
multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
|
||||
multiGetRequest.preference(request.param("preference"));
|
||||
multiGetRequest.realtime(request.paramAsBoolean("realtime", null));
|
||||
multiGetRequest.realtime(request.paramAsBoolean("realtime", multiGetRequest.realtime()));
|
||||
multiGetRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));
|
||||
|
||||
String[] sFields = null;
|
||||
|
|
|
@ -83,7 +83,7 @@ public class RestPercolateAction extends BaseRestHandler {
|
|||
getRequest.routing(restRequest.param("routing"));
|
||||
getRequest.preference(restRequest.param("preference"));
|
||||
getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh()));
|
||||
getRequest.realtime(restRequest.paramAsBoolean("realtime", null));
|
||||
getRequest.realtime(restRequest.paramAsBoolean("realtime", getRequest.realtime()));
|
||||
getRequest.version(RestActions.parseVersion(restRequest));
|
||||
getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType()));
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public class RestTermVectorsAction extends BaseRestHandler {
|
|||
termVectorsRequest.positions(request.paramAsBoolean("positions", termVectorsRequest.positions()));
|
||||
termVectorsRequest.payloads(request.paramAsBoolean("payloads", termVectorsRequest.payloads()));
|
||||
termVectorsRequest.routing(request.param("routing"));
|
||||
termVectorsRequest.realtime(request.paramAsBoolean("realtime", null));
|
||||
termVectorsRequest.realtime(request.paramAsBoolean("realtime", termVectorsRequest.realtime()));
|
||||
termVectorsRequest.version(RestActions.parseVersion(request, termVectorsRequest.version()));
|
||||
termVectorsRequest.versionType(VersionType.fromString(request.param("version_type"), termVectorsRequest.versionType()));
|
||||
termVectorsRequest.parent(request.param("parent"));
|
||||
|
|
|
@ -46,11 +46,8 @@ curl -XHEAD -i 'http://localhost:9200/twitter/tweet/1'
|
|||
=== Realtime
|
||||
|
||||
By default, the get API is realtime, and is not affected by the refresh
|
||||
rate of the index (when data will become visible for search).
|
||||
|
||||
In order to disable realtime GET, one can either set `realtime`
|
||||
parameter to `false`, or globally default it to by setting the
|
||||
`action.get.realtime` to `false` in the node configuration.
|
||||
rate of the index (when data will become visible for search). In order
|
||||
to disable realtime GET, one can set `realtime` parameter to `false`.
|
||||
|
||||
When getting a document, one can specify `fields` to fetch from it. They
|
||||
will, when possible, be fetched as stored fields (fields mapped as
|
||||
|
|
|
@ -231,3 +231,10 @@ The `discovery.zen.minimum_master_node` must bet set for nodes that have
|
|||
`transport.host`, `transport.bind_host`, or `transport.publish_host`
|
||||
configuration options set. We see those nodes as in "production" mode
|
||||
and thus require the setting.
|
||||
|
||||
==== Realtime get setting
|
||||
|
||||
The `action.get.realtime` setting has been removed. This setting was
|
||||
a fallback realtime setting for the get and mget APIs when realtime
|
||||
wasn't specified. Now if the parameter isn't specified we always
|
||||
default to true.
|
Loading…
Reference in New Issue