Adding PIT id to the Search request body through Java SDK

While fetching paginated results back from elastic search we need to construct a query like this

  "size": 10000,
  "query": {
    "match" : {
      "" : "elkbee"
  "pit": {
	    "keep_alive": "1m"
  "sort": [ 
    {"@timestamp": "asc"}

How to create the same query with the Java API using Rest- High Level Client

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.pit; ???????? //UNKNOWN

Is the above approach correct and how to add the Pit Parameter to the query too?

Please revert ASAP

1 Like

You already asked a similar question at Creation of PIT using Rest High Level Client in Java SDK.

Let's keep the same discussion in one place. Thanks.

Please be patient in waiting for responses to your question and refrain from pinging multiple times asking for a response or opening multiple topics for the same question. This is a community forum, it may take time for someone to reply to your question. For more information please refer to the Community Code of Conduct specifically the section "Be patient". Also, please refrain from pinging folks directly, this is a forum and anyone that participates might be able to assist you.

If you are in need of a service with an SLA that covers response times for questions then you may want to consider talking to us about a subscription.

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

This question was unrelated to the previous question as it refers to adding more fields to the search request body so I created a new topic we can continue this discussion on the earlier thread also if it is against the policy.

I thought your question was related to PIT.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.