Elastic App Search Analytics Queries Pagination

Hello there,

Using Enterprise Search PHP I am trying to fetch the analytics queries as it is documented here.

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!

Hi @Thymen !

You can use AnalyticsQueriesParams to specify the Page information. This will allow to set the current page you want to retrieve.

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

Hope that helps!

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.

  $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!

Hey @Carlos_D ,

Any updates at to how I could solve this issue?

Thanks again!

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

My bad. There's also a Page in the AppSearch namespace that should do the trick.

Hope this helps!

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