How to change the default response payload 10 to a custom number in app search php client

I was using the app-search php client for my application using below code block. What it does is that, get the results from a app-search engine based on the query we provide in the $search variable.

$search = new Schema\SearchRequestParams($search);
$client = new ElasticEnterpriseSearchClient([
    'host' => 'http://<App-Search-IP>:<Port>',
    'app-search' => [
        'token' => '<API token>'
    ]
    
]);
$appSearch = $client->appSearch();
$result = $appSearch->search(new ElasticAppSearchRequest\Search('dvf-data', $search))->asArray();
use Elastic\EnterpriseSearch\Client as ElasticEnterpriseSearchClient;
use Elastic\EnterpriseSearch\AppSearch\Request as ElasticAppSearchRequest;
use Elastic\EnterpriseSearch\AppSearch\Schema;

These are the packages I'm using

I get the response but there is only 10 results in the array, how can I increase that response value like to 100 or 1000? I have also checked the app-search PHP client doc, but did not find a solution there.

Note: I'm using ES and APP-Search version 8.3.3

Any help would be appreciated! :slight_smile:

The size of the result set can be adjusted using the page.size parameter on your request. Search API | Elastic App Search Documentation [8.4] | Elastic

Hi @JasonStoltz

Thanks for you reply.
I saw that in the documentation, but my question is how can we pass it in the below code block. it only accepts engine name and the search keyword. How to set/[pass the other parameters to that funtion?

Have you checked the docs for the PHP client? I'm guessing the answer is there.

Hi @JasonStoltz

Yes, I did check the documentation. I guess below doc is the correct one.
app-search php client

Hi @Dhanushka_Samarasing ,
for setting the size parameter you need to create a Schema\Page object and assign it to page property of Request\Search, as follows:

$appSearch = $client->appSearch();
$request = new ElasticAppSearchRequest\Search('dvf-data', $search);
$request->page = new Schema\Page(100);
$result = $appSearch->search($request)->asArray();

We should definitely improve our documentation here :slight_smile:
Let me know if you need more assistance, thanks.

1 Like

Hi @ezimuel ,
Thanks for your reply.