Class OpenPointInTimeRequest
- All Implemented Interfaces:
JsonpSerializable
A search request by default runs against the most recent visible data of the
target indices, which is called point in time. Elasticsearch pit (point in
time) is a lightweight view into the state of the data as it existed when
initiated. In some cases, it’s preferred to perform multiple search requests
using the same point in time. For example, if refreshes happen between
search_after
requests, then the results of those requests might
not be consistent as changes happening between searches are only visible to
the more recent point in time.
A point in time must be opened explicitly before being used in search requests.
A subsequent search request with the pit
parameter must not
specify index
, routing
, or preference
values as these parameters are copied from the point in time.
Just like regular searches, you can use from
and
size
to page through point in time search results, up to the
first 10,000 hits. If you want to retrieve more hits, use PIT with
search_after
.
IMPORTANT: The open point in time request and each subsequent search request can return different identifiers; always use the most recently received ID for the next search request.
When a PIT that contains shard failures is used in a search request, the
missing are always reported in the search response as a
NoShardAvailableActionException
exception. To get rid of these
exceptions, a new PIT needs to be created so that shards missing from the
previous PIT can be handled, assuming they become available in the meantime.
Keeping point in time alive
The keep_alive
parameter, which is passed to a open point in
time request and search request, extends the time to live of the
corresponding point in time. The value does not need to be long enough to
process all data — it just needs to be long enough for the next request.
Normally, the background merge process optimizes the index by merging together smaller segments to create new, bigger segments. Once the smaller segments are no longer needed they are deleted. However, open point-in-times prevent the old segments from being deleted since they are still in use.
TIP: Keeping older segments alive means that more disk space and file handles are needed. Ensure that you have configured your nodes to have ample free file handles.
Additionally, if a segment contains deleted or updated documents then the point in time must keep track of whether each document in the segment was live at the time of the initial search request. Ensure that your nodes have sufficient heap space if you have many open point-in-times on an index that is subject to ongoing deletes or updates. Note that a point-in-time doesn't prevent its associated indices from being deleted. You can check how many point-in-times (that is, search contexts) are open with the nodes stats API.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class co.elastic.clients.elasticsearch._types.RequestBase
RequestBase.AbstractBuilder<BuilderT extends RequestBase.AbstractBuilder<BuilderT>>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JsonpDeserializer<OpenPointInTimeRequest>
Json deserializer forOpenPointInTimeRequest
static final Endpoint<OpenPointInTimeRequest,
OpenPointInTimeResponse, ErrorResponse> Endpoint "open_point_in_time
". -
Method Summary
Modifier and TypeMethodDescriptionfinal Boolean
Indicates whether the point in time tolerates unavailable shards or shard failures when initially creating the PIT.final List<ExpandWildcard>
The type of index that wildcard patterns can match.final Boolean
Iffalse
, the request returns an error if it targets a missing or closed index.index()
Required - A comma-separated list of index names to open point in time; use_all
or empty string to perform the operation on all indicesfinal Query
Filter indices if the provided query rewrites tomatch_none
on every shard.final Time
Required - Extend the length of time that the point in time persists.final Integer
Maximum number of concurrent shard requests that each sub-search request executes per node.static OpenPointInTimeRequest
final String
The node or shard the operation should be performed on.final String
routing()
A custom value that is used to route operations to a specific shard.void
serialize
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) Serialize this object to JSON.protected void
serializeInternal
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) protected static void
Methods inherited from class co.elastic.clients.elasticsearch._types.RequestBase
toString
-
Field Details
-
_DESERIALIZER
Json deserializer forOpenPointInTimeRequest
-
_ENDPOINT
public static final Endpoint<OpenPointInTimeRequest,OpenPointInTimeResponse, _ENDPOINTErrorResponse> Endpoint "open_point_in_time
".
-
-
Method Details
-
of
public static OpenPointInTimeRequest of(Function<OpenPointInTimeRequest.Builder, ObjectBuilder<OpenPointInTimeRequest>> fn) -
allowPartialSearchResults
Indicates whether the point in time tolerates unavailable shards or shard failures when initially creating the PIT. Iffalse
, creating a point in time request when a shard is missing or unavailable will throw an exception. Iftrue
, the point in time will contain all the shards that are available at the time of the request.API name:
allow_partial_search_results
-
expandWildcards
The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. It supports comma-separated values, such asopen,hidden
. Valid values are:all
,open
,closed
,hidden
,none
.API name:
expand_wildcards
-
index
Required - A comma-separated list of index names to open point in time; use_all
or empty string to perform the operation on all indicesAPI name:
index
-
indexFilter
Filter indices if the provided query rewrites tomatch_none
on every shard.API name:
index_filter
-
keepAlive
Required - Extend the length of time that the point in time persists.API name:
keep_alive
-
maxConcurrentShardRequests
Maximum number of concurrent shard requests that each sub-search request executes per node.API name:
max_concurrent_shard_requests
-
preference
The node or shard the operation should be performed on. By default, it is random.API name:
preference
-
routing
A custom value that is used to route operations to a specific shard.API name:
routing
-
serialize
Serialize this object to JSON.- Specified by:
serialize
in interfaceJsonpSerializable
-
serializeInternal
-
setupOpenPointInTimeRequestDeserializer
protected static void setupOpenPointInTimeRequestDeserializer(ObjectDeserializer<OpenPointInTimeRequest.Builder> op)
-