Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

onurzdgn's avatar

I need more data on API

I am using curl and elasticsearch. And this is my controller: public function test() { return Http::get('localhost:9200/test/_search')['hits']['hits']; } This is give me 10 doc(data) from elasticsearch but I have 49.985 docs(data). How I take doc(data) thousand by a thousand.

0 likes
5 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

You can use the size and from parameters in your query to paginate the results. For example, to get the first 1000 documents, you can use the following query:

public function test() { 
    return Http::get('localhost:9200/test/_search?size=1000&from=0')['hits']['hits']; 
}

To get the next 1000 documents, you can use the following query:

public function test() { 
    return Http::get('localhost:9200/test/_search?size=1000&from=1000')['hits']['hits']; 
}

You can keep incrementing the from parameter by 1000 until you have retrieved all the documents.

1 like
onurzdgn's avatar

@LaryAI Thank you. I want to ask someting to. If I create a table 0-10.000 docs. If the user want 10.000 doc. How I create a responsive paginete?

Sinnbeck's avatar

@onurzdgn it's an ai. It cannot do followups. But you just replace 1000 with a variable

1 like

Please or to participate in this conversation.