Elasticsearch php help


(Akhil Prashar) #1

I am getting all the results of elasticsearch through my php interface. Now I need to show 20 results per page, and idea is total number of hits divided by 20 equals number of pages. And as I need 20 results per page can anyone help me with the code how to write it?

Thanks
Akhil


(Vishnu Gt) #2

If you wanted to show five results per page, then pages 1 to 3 could be requested as follows:

GET /_search?size=20
GET /_search?size=20&from=20
GET /_search?size=20&from=40


(Akhil Prashar) #3

I get this size and from thing. Actually I am needing help in php, about how to write the logic into code.


(Vishnu Gt) #4

Display the first 20 results by calling this URL /_search?size=20 and have an option called load more, and when he clicks it fire this URL /_search?size=20&from=20 and keep adding 20 to the 'from' param in the URL each time he clicks load more.

You can also have like pagination with page numbers.
So each page result would be /_search?size=20&from={page_number-1}*20


(Vishnu Gt) #5

If your problem is solved please select the answer that solved your problem. Regards.


(Akhil Prashar) #6

thanks mate


(system) #7

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