# Elastic App Search Analytics Queries Pagination

**URL:** https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275
**Category:** Elastic Search
**Tags:** elastic-app-search
**Created:** [April 19, 2023, 8:15am UTC](https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275 "2023-04-19T08:15:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Thymen](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@Thymen](https://discuss.elastic.co/u/Thymen)
#### Post date: [April 19, 2023, 8:15am UTC](https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275/1 "2023-04-19T08:15:33Z")

</div>

Hello there,

Using [Enterprise Search PHP](https://github.com/elastic/enterprise-search-php) I am trying to fetch the analytics queries as it is documented [here](https://www.elastic.co/guide/en/app-search/8.7/queries.html).

Now I know that the limit to the amount of records returned per page is 1000 records. My user case requires me to fetch the maximum amount of records possible for analytics purposes. Which is why I am trying to loop over the pages to reach the maximum amount of records. However I can't seem to find the option to loop over the pages anywhere in the documentation. I'm sure that is must be possible as the result always returns the amount of records and the current page, which is why I am asking how I could possibly fetch the other pages.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)
#### Post date: [April 19, 2023, 8:44am UTC](https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275/2 "2023-04-19T08:44:06Z")

</div>

Hi @Thymen !

You can use [AnalyticsQueriesParams](https://github.com/elastic/enterprise-search-php/blob/main/src/AppSearch/Schema/AnalyticsQueriesParams.php#L22) to specify the [Page](https://github.com/elastic/enterprise-search-php/blob/main/src/WorkplaceSearch/Schema/Page.php#L23) information. This will allow to set the [current](https://github.com/elastic/enterprise-search-php/blob/main/src/WorkplaceSearch/Schema/Page.php#L25) page you want to retrieve.

This way, you can iterate changing the `current` page value in the parameter.

Hope that helps!

---

<div class="post-metadata">

### Author: ![Thymen](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@Thymen](https://discuss.elastic.co/u/Thymen)
#### Post date: [April 19, 2023, 8:59am UTC](https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275/3 "2023-04-19T08:59:25Z")

</div>

Hey @Carlos_D !

Thanks a lot for the quick response! However it seems that the AnalyticsQueriesParams expects an AppSearch\Schema\Page instead of a WorkplaceSearch\Schema\Page, which results in the following error:

> Cannot assign Elastic\EnterpriseSearch\WorkplaceSearch\Schema\Page to property Elastic\EnterpriseSearch\AppSearch\Schema\AnalyticsQueriesParams::$page of type Elastic\EnterpriseSearch\AppSearch\Schema\Page

I've posted the code that is producing this error beneath this paragraph, maybe that will make it easier to solve.

```auto
  $page = new Page(2, 10, 10, 1000);
  $params = new AnalyticsQueriesParams();
  $params->page = $page;
  $request = new GetTopQueriesAnalytics('enginename', $params);
  $result = ElasticClient::getInstance()->getAppSearch()->appSearch()->getTopQueriesAnalytics(
      $request
  );
  $result = $result->asArray()['results'];

```

When I use the AppSearch\Schema\Page it works, but that class only accepts the size parameter.

Thanks again!

---

<div class="post-metadata">

### Author: ![Thymen](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@Thymen](https://discuss.elastic.co/u/Thymen)
#### Post date: [May 10, 2023, 9:56am UTC](https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275/4 "2023-05-10T09:56:32Z")

</div>

Hey @Carlos_D ,

Any updates at to how I could solve this issue?

Thanks again!

---

<div class="post-metadata">

### Author: ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)
#### Post date: [May 12, 2023, 8:16am UTC](https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275/5 "2023-05-12T08:16:48Z")

</div>

hey @Thymen ! Sorry about the delay in getting back to you!

My bad. There's also a [Page](https://github.com/elastic/enterprise-search-php/blob/main/src/AppSearch/Schema/Page.php) in the AppSearch namespace that should do the trick.

Hope this helps!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 9, 2023, 8:17am UTC](https://discuss.elastic.co/t/elastic-app-search-analytics-queries-pagination/330275/6 "2023-06-09T08:17:17Z")

</div>

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