Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Search after with a PIT
# Creat a PIT (Point in Time)
POST /auditbeat-8.0.0/_pit?keep_alive=10m

# First page of 2 items (no "search_after" specified)
GET /_search
{
  "size": 2, 
  "pit": {
    "id": "46ToAwEhYXVkaXRiZWF0LTguMC4wLTIwMjIuMDIuMTQtMDAwMDAxFmI2ZEk1NnMtUlZxM25hY3ZkeUVnN2cAFk0tblloZ2RYUjVDWUJLQUhYUHNmdHcAAAAAAAAEnSMWR0NfVWdlakZSSEszcGVzbXpfSTdoZwABFmI2ZEk1NnMtUlZxM25hY3ZkeUVnN2cAAA==",
    "keep_alive": "10m"
  },
  "sort": [
    {
      "_shard_doc": "desc"
    }
  ]
}

# Second page by taking the returned sort from the first query above ("search_after" specified).
GET /_search
{
  "size": 2,
  "pit": {
    "id": "46ToAwEhYXVkaXRiZWF0LTguMC4wLTIwMjIuMDIuMTQtMDAwMDAxFmI2ZEk1NnMtUlZxM25hY3ZkeUVnN2cAFk0tblloZ2RYUjVDWUJLQUhYUHNmdHcAAAAAAAAEnSMWR0NfVWdlakZSSEszcGVzbXpfSTdoZwABFmI2ZEk1NnMtUlZxM25hY3ZkeUVnN2cAAA==",
    "keep_alive": "10m"
  },
  "sort": [
    {
      "_shard_doc": "desc"
    }
  ],
  "search_after": [175296]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment