Search after in spring

Hi all,

I'm try to search in ES via spring boot, and I have a stuck with search after .
So I have a search api look like below:

GET /domain/_search
"size": 1000,
"query": {
"bool": {
"must": [
{"match": {
"location": "chi minh"
"sort": [
{"uid": "asc"}
"search_after": ["-1_GV8BvdYWz-mSbJ8JcgQ=="]

I do some research but not find the way to implement this query on spring.
Can anybody suggest me the best way to implement that.
Thanks you.

The SearchRequest object has a source(SearchSourceBuilder) method. You can create a new SearchSourceBuilder() object which exposes a searchAfter(Object[]) method which I guess you can use for that :slight_smile: .

1 Like

thank for your suggestion, It worked for me :slightly_smiling_face:
Here is my implementation:

SearchRequest searchRequest = new SearchRequest("domain");
SearchResponse searchResponse = elasticsearchTemplate.getClient().search(searchRequest).actionGet();

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