Sep 25, 2025
Run a Composition
Runs a query on a single composition and returns matching results.
Usage
Required ACL:
search
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use Algolia\AlgoliaSearch\Api\CompositionClient;
$client = CompositionClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
$response = $client->search(
'foo',
['params' => ['query' => 'batman',
'injectedItems' => ['injectedItem1' => ['items' => [
['objectID' => 'my-object-1',
],
['objectID' => 'my-object-2',
'metadata' => ['my-string' => 'string',
'my-bool' => true,
'my-number' => 42,
'my-object' => ['sub-key' => 'sub-value'],
],
],
],
],
],
],
],
);