Elasticsearch node js search_after

Hello everyone! Does anyone know how to properly use search_after in the elastic query in node js?
I've tried like :

'''const body = {  "query": {    "geo_shape": {      "geometry": {        "relation": "within",         "shape": {          "type": "polygon",          "coordinates": [$polygon]        }      }    }  },  "pit": {	    "id":  $newPIT, 	    "keep_alive": "1m"  },
              "sort": [
                {"@timestamp": "asc"}
              ],
              "search_after": $searchAfter
            };
            return client.search({
              size:10000,
              body: body,
            }

and

const body = {  "query": {    "geo_shape": {      "geometry": {        "relation": "within",         "shape": {          "type": "polygon",          "coordinates": [$polygon]        }      }    }  },  "pit": {	    "id":  $newPIT, 	    "keep_alive": "1m"  },
              "sort": [
                {"@timestamp": "asc"}
              ],
            };
         body.search_after = $searchAfter;
            console.log(body)
            return client.search({
              size:10000,
              body: body,
            }

$searchAfter variable is taken from the first query after which I would paginate. The value of this variable is something like [ 9223372036854776000, 32291 ].
I am getting search_phase_execution_exception.
In Kibana query like this works for me, so the problem is the usage of search_after in node js.

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