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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Composition;
var client = new CompositionClient(
new CompositionConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
);
var response = await client.SearchAsync<Hit>(
"foo",
new RequestBody
{
Params = new Params
{
Query = "batman",
InjectedItems = new Dictionary<string, ExternalInjectedItem>
{
{
"injectedItem1",
new ExternalInjectedItem
{
Items = new List<ExternalInjection>
{
new ExternalInjection { ObjectID = "my-object-1" },
new ExternalInjection
{
ObjectID = "my-object-2",
Metadata = new Dictionary<string, object>
{
{ "my-string", "string" },
{ "my-bool", true },
{ "my-number", 42 },
{
"my-object",
new Dictionary<string, object> { { "sub-key", "sub-value" } }
},
},
},
},
}
},
},
},
}
);