curl
curl --request POST \
--url 'https://algolia_application_id.algolia.net/1/indexes/*/queries' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"requests": [
{
"params": "hitsPerPage=2&getRankingInfo=1",
"indexName": "products",
"type": "default",
"extensions": {
"queryCategorization": {
"enableCategoriesRetrieval": false,
"enableAutoFiltering": false
}
}
}
],
"strategy": "none"
}
'// Initialize the client
var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SearchAsync<Hit>(
new SearchMethodParams
{
Requests = new List<SearchQuery>
{
new SearchQuery(new SearchForHits { IndexName = "<YOUR_INDEX_NAME>" }),
new SearchQuery(
new SearchForFacets
{
IndexName = "<YOUR_INDEX_NAME>",
Type = Enum.Parse<SearchTypeFacet>("Facet"),
Facet = "theFacet",
}
),
new SearchQuery(
new SearchForHits
{
IndexName = "<YOUR_INDEX_NAME>",
Type = Enum.Parse<SearchTypeDefault>("Default"),
}
),
},
Strategy = Enum.Parse<SearchStrategy>("StopIfEnoughMatches"),
}
);
// print the response
Console.WriteLine(response);// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.search(
searchMethodParams: SearchMethodParams(
requests: [
SearchForHits(
indexName: "<YOUR_INDEX_NAME>",
),
SearchForFacets(
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeFacet.fromJson("facet"),
facet: "theFacet",
),
SearchForHits(
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeDefault.fromJson("default"),
),
],
strategy: SearchStrategy.fromJson("stopIfEnoughMatches"),
),
);
// print the response
print(response);// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.Search(client.NewApiSearchRequest(
search.NewEmptySearchMethodParams().SetRequests(
[]search.SearchQuery{*search.SearchForHitsAsSearchQuery(
search.NewEmptySearchForHits().SetIndexName("<YOUR_INDEX_NAME>")), *search.SearchForFacetsAsSearchQuery(
search.NewEmptySearchForFacets().SetIndexName("<YOUR_INDEX_NAME>").SetType(search.SearchTypeFacet("facet")).SetFacet("theFacet")), *search.SearchForHitsAsSearchQuery(
search.NewEmptySearchForHits().SetIndexName("<YOUR_INDEX_NAME>").SetType(search.SearchTypeDefault("default")))}).SetStrategy(search.SearchStrategy("stopIfEnoughMatches"))))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
// Call the API
SearchResponses response = client.search(
new SearchMethodParams().setRequests(
Arrays.asList(new SearchForHits().setIndexName("<YOUR_INDEX_NAME>").setQuery("<YOUR_QUERY>").setHitsPerPage(50))
),
Hit.class
);
// print the response
System.out.println(response);// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
const response = await client.search({
requests: [
{ indexName: 'theIndexName' },
{ indexName: 'theIndexName2', type: 'facet', facet: 'theFacet' },
{ indexName: 'theIndexName', type: 'default' },
],
strategy: 'stopIfEnoughMatches',
});
// print the response
console.log(response);// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
var response =
client.search(
searchMethodParams =
SearchMethodParams(
requests =
listOf(
SearchForHits(
indexName = "<YOUR_INDEX_NAME>",
query = "<YOUR_QUERY>",
hitsPerPage = 50,
)
)
)
)
// print the response
println(response)// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
$response = $client->search(
['requests' => [
['indexName' => '<YOUR_INDEX_NAME>',
],
['indexName' => '<YOUR_INDEX_NAME>',
'type' => 'facet',
'facet' => 'theFacet',
],
['indexName' => '<YOUR_INDEX_NAME>',
'type' => 'default',
],
],
'strategy' => 'stopIfEnoughMatches',
],
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use SearchClient instead, which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search(
search_method_params={
"requests": [
{
"indexName": "<YOUR_INDEX_NAME>",
},
{
"indexName": "<YOUR_INDEX_NAME>",
"type": "facet",
"facet": "theFacet",
},
{
"indexName": "<YOUR_INDEX_NAME>",
"type": "default",
},
],
"strategy": "stopIfEnoughMatches",
},
)
# print the response
print(response)# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search(
Algolia::Search::SearchMethodParams.new(
requests: [
Algolia::Search::SearchForHits.new(index_name: "<YOUR_INDEX_NAME>"),
Algolia::Search::SearchForFacets.new(index_name: "<YOUR_INDEX_NAME>", type: "facet", facet: "theFacet"),
Algolia::Search::SearchForHits.new(index_name: "<YOUR_INDEX_NAME>", type: "default")
],
strategy: "stopIfEnoughMatches"
)
)
# print the response
puts(response)// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.search(
searchMethodParams = SearchMethodParams(
requests = Seq(
SearchForHits(
indexName = "<YOUR_INDEX_NAME>"
),
SearchForFacets(
indexName = "<YOUR_INDEX_NAME>",
`type` = SearchTypeFacet.withName("facet"),
facet = "theFacet"
),
SearchForHits(
indexName = "<YOUR_INDEX_NAME>",
`type` = Some(SearchTypeDefault.withName("default"))
)
),
strategy = Some(SearchStrategy.withName("stopIfEnoughMatches"))
)
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY")
// Call the API
let response: SearchResponses<Hit> = try await client.search(searchMethodParams: SearchMethodParams(
requests: [
SearchQuery.searchForHits(SearchForHits(indexName: "<YOUR_INDEX_NAME>")),
SearchQuery.searchForFacets(SearchForFacets(
facet: "theFacet",
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeFacet.facet
)),
SearchQuery.searchForHits(SearchForHits(
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeDefault.`default`
)),
],
strategy: SearchStrategy.stopIfEnoughMatches
))
// print the response
print(response){
"results": [
{
"hits": [
{
"objectID": "test-record-123",
"_distinctSeqID": 123,
"_highlightResult": {},
"_rankingInfo": {
"firstMatchedWord": 1,
"geoDistance": 1,
"nbExactWords": 1,
"nbTypos": 1,
"userScore": 123,
"filters": 1,
"geoPrecision": 2,
"matchedGeoLocation": {
"distance": 123,
"lat": 123,
"lng": 123
},
"personalization": {
"filtersScore": 123,
"rankingScore": 123,
"score": 123
},
"promoted": true,
"promotedByReRanking": true,
"proximityDistance": 1,
"words": 2
},
"_snippetResult": {}
}
],
"_automaticInsights": true,
"abTestID": 123,
"abTestVariantID": 2,
"appliedRules": [
{}
],
"aroundLatLng": "40.71,-74.01",
"automaticRadius": "<string>",
"exhaustive": {
"facetsCount": true,
"facetValues": true,
"nbHits": true,
"rulesMatch": true,
"typo": true
},
"exhaustiveFacetsCount": true,
"exhaustiveNbHits": true,
"exhaustiveTypo": true,
"facets": {
"category": {
"food": 1,
"tech": 42
}
},
"facets_stats": {},
"index": "indexName",
"indexUsed": "indexNameAlt",
"message": "<string>",
"nbSortedHits": 20,
"parsedQuery": "george clo",
"processingTimeMS": 20,
"processingTimingsMS": {},
"queryAfterRemoval": "<string>",
"queryID": "a00dbc80a8d13c4565a442e7e2dca80a",
"redirect": {
"index": [
{
"data": {
"ruleObjectID": "<string>"
},
"dest": "<string>",
"reason": "<string>",
"source": "<string>",
"succeed": true
}
]
},
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"title": "<string>",
"urls": [
{
"url": "<string>"
}
]
},
"link": {
"url": "<string>"
}
}
]
}
},
"serverTimeMS": 20,
"serverUsed": "c2-uk-3.algolia.net",
"userData": {
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
},
"hitsPerPage": 20,
"nbHits": 20,
"nbPages": 1,
"page": 0,
"extensions": {
"queryCategorization": {
"autofiltering": {
"enabled": true,
"facetFilters": [
"<string>"
],
"maxDepth": 123,
"optionalFilters": [
"<string>"
]
},
"categories": [
{
"hierarchyPath": [
{
"depth": 123,
"facetName": "<string>",
"facetValue": "<string>"
}
]
}
],
"count": 123,
"normalizedQuery": "<string>"
}
},
"params": "query=a&hitsPerPage=20",
"query": ""
}
]
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}Search
Search multiple queries
Runs multiple search queries against one or more indices in a single API request.
POST
/
1
/
indexes
/
*
/
queries
curl
curl --request POST \
--url 'https://algolia_application_id.algolia.net/1/indexes/*/queries' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"requests": [
{
"params": "hitsPerPage=2&getRankingInfo=1",
"indexName": "products",
"type": "default",
"extensions": {
"queryCategorization": {
"enableCategoriesRetrieval": false,
"enableAutoFiltering": false
}
}
}
],
"strategy": "none"
}
'// Initialize the client
var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SearchAsync<Hit>(
new SearchMethodParams
{
Requests = new List<SearchQuery>
{
new SearchQuery(new SearchForHits { IndexName = "<YOUR_INDEX_NAME>" }),
new SearchQuery(
new SearchForFacets
{
IndexName = "<YOUR_INDEX_NAME>",
Type = Enum.Parse<SearchTypeFacet>("Facet"),
Facet = "theFacet",
}
),
new SearchQuery(
new SearchForHits
{
IndexName = "<YOUR_INDEX_NAME>",
Type = Enum.Parse<SearchTypeDefault>("Default"),
}
),
},
Strategy = Enum.Parse<SearchStrategy>("StopIfEnoughMatches"),
}
);
// print the response
Console.WriteLine(response);// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.search(
searchMethodParams: SearchMethodParams(
requests: [
SearchForHits(
indexName: "<YOUR_INDEX_NAME>",
),
SearchForFacets(
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeFacet.fromJson("facet"),
facet: "theFacet",
),
SearchForHits(
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeDefault.fromJson("default"),
),
],
strategy: SearchStrategy.fromJson("stopIfEnoughMatches"),
),
);
// print the response
print(response);// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.Search(client.NewApiSearchRequest(
search.NewEmptySearchMethodParams().SetRequests(
[]search.SearchQuery{*search.SearchForHitsAsSearchQuery(
search.NewEmptySearchForHits().SetIndexName("<YOUR_INDEX_NAME>")), *search.SearchForFacetsAsSearchQuery(
search.NewEmptySearchForFacets().SetIndexName("<YOUR_INDEX_NAME>").SetType(search.SearchTypeFacet("facet")).SetFacet("theFacet")), *search.SearchForHitsAsSearchQuery(
search.NewEmptySearchForHits().SetIndexName("<YOUR_INDEX_NAME>").SetType(search.SearchTypeDefault("default")))}).SetStrategy(search.SearchStrategy("stopIfEnoughMatches"))))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
// Call the API
SearchResponses response = client.search(
new SearchMethodParams().setRequests(
Arrays.asList(new SearchForHits().setIndexName("<YOUR_INDEX_NAME>").setQuery("<YOUR_QUERY>").setHitsPerPage(50))
),
Hit.class
);
// print the response
System.out.println(response);// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
const response = await client.search({
requests: [
{ indexName: 'theIndexName' },
{ indexName: 'theIndexName2', type: 'facet', facet: 'theFacet' },
{ indexName: 'theIndexName', type: 'default' },
],
strategy: 'stopIfEnoughMatches',
});
// print the response
console.log(response);// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
var response =
client.search(
searchMethodParams =
SearchMethodParams(
requests =
listOf(
SearchForHits(
indexName = "<YOUR_INDEX_NAME>",
query = "<YOUR_QUERY>",
hitsPerPage = 50,
)
)
)
)
// print the response
println(response)// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
$response = $client->search(
['requests' => [
['indexName' => '<YOUR_INDEX_NAME>',
],
['indexName' => '<YOUR_INDEX_NAME>',
'type' => 'facet',
'facet' => 'theFacet',
],
['indexName' => '<YOUR_INDEX_NAME>',
'type' => 'default',
],
],
'strategy' => 'stopIfEnoughMatches',
],
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use SearchClient instead, which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search(
search_method_params={
"requests": [
{
"indexName": "<YOUR_INDEX_NAME>",
},
{
"indexName": "<YOUR_INDEX_NAME>",
"type": "facet",
"facet": "theFacet",
},
{
"indexName": "<YOUR_INDEX_NAME>",
"type": "default",
},
],
"strategy": "stopIfEnoughMatches",
},
)
# print the response
print(response)# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search(
Algolia::Search::SearchMethodParams.new(
requests: [
Algolia::Search::SearchForHits.new(index_name: "<YOUR_INDEX_NAME>"),
Algolia::Search::SearchForFacets.new(index_name: "<YOUR_INDEX_NAME>", type: "facet", facet: "theFacet"),
Algolia::Search::SearchForHits.new(index_name: "<YOUR_INDEX_NAME>", type: "default")
],
strategy: "stopIfEnoughMatches"
)
)
# print the response
puts(response)// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.search(
searchMethodParams = SearchMethodParams(
requests = Seq(
SearchForHits(
indexName = "<YOUR_INDEX_NAME>"
),
SearchForFacets(
indexName = "<YOUR_INDEX_NAME>",
`type` = SearchTypeFacet.withName("facet"),
facet = "theFacet"
),
SearchForHits(
indexName = "<YOUR_INDEX_NAME>",
`type` = Some(SearchTypeDefault.withName("default"))
)
),
strategy = Some(SearchStrategy.withName("stopIfEnoughMatches"))
)
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY")
// Call the API
let response: SearchResponses<Hit> = try await client.search(searchMethodParams: SearchMethodParams(
requests: [
SearchQuery.searchForHits(SearchForHits(indexName: "<YOUR_INDEX_NAME>")),
SearchQuery.searchForFacets(SearchForFacets(
facet: "theFacet",
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeFacet.facet
)),
SearchQuery.searchForHits(SearchForHits(
indexName: "<YOUR_INDEX_NAME>",
type: SearchTypeDefault.`default`
)),
],
strategy: SearchStrategy.stopIfEnoughMatches
))
// print the response
print(response){
"results": [
{
"hits": [
{
"objectID": "test-record-123",
"_distinctSeqID": 123,
"_highlightResult": {},
"_rankingInfo": {
"firstMatchedWord": 1,
"geoDistance": 1,
"nbExactWords": 1,
"nbTypos": 1,
"userScore": 123,
"filters": 1,
"geoPrecision": 2,
"matchedGeoLocation": {
"distance": 123,
"lat": 123,
"lng": 123
},
"personalization": {
"filtersScore": 123,
"rankingScore": 123,
"score": 123
},
"promoted": true,
"promotedByReRanking": true,
"proximityDistance": 1,
"words": 2
},
"_snippetResult": {}
}
],
"_automaticInsights": true,
"abTestID": 123,
"abTestVariantID": 2,
"appliedRules": [
{}
],
"aroundLatLng": "40.71,-74.01",
"automaticRadius": "<string>",
"exhaustive": {
"facetsCount": true,
"facetValues": true,
"nbHits": true,
"rulesMatch": true,
"typo": true
},
"exhaustiveFacetsCount": true,
"exhaustiveNbHits": true,
"exhaustiveTypo": true,
"facets": {
"category": {
"food": 1,
"tech": 42
}
},
"facets_stats": {},
"index": "indexName",
"indexUsed": "indexNameAlt",
"message": "<string>",
"nbSortedHits": 20,
"parsedQuery": "george clo",
"processingTimeMS": 20,
"processingTimingsMS": {},
"queryAfterRemoval": "<string>",
"queryID": "a00dbc80a8d13c4565a442e7e2dca80a",
"redirect": {
"index": [
{
"data": {
"ruleObjectID": "<string>"
},
"dest": "<string>",
"reason": "<string>",
"source": "<string>",
"succeed": true
}
]
},
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"title": "<string>",
"urls": [
{
"url": "<string>"
}
]
},
"link": {
"url": "<string>"
}
}
]
}
},
"serverTimeMS": 20,
"serverUsed": "c2-uk-3.algolia.net",
"userData": {
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
},
"hitsPerPage": 20,
"nbHits": 20,
"nbPages": 1,
"page": 0,
"extensions": {
"queryCategorization": {
"autofiltering": {
"enabled": true,
"facetFilters": [
"<string>"
],
"maxDepth": 123,
"optionalFilters": [
"<string>"
]
},
"categories": [
{
"hierarchyPath": [
{
"depth": 123,
"facetName": "<string>",
"facetValue": "<string>"
}
]
}
],
"count": 123,
"normalizedQuery": "<string>"
}
},
"params": "query=a&hitsPerPage=20",
"query": ""
}
]
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}Use cases include:
- Searching different indices, such as products and marketing content.
- Run multiple queries on the same index with different parameters or filters.
searchForHits or searchForFacets helper to simplify the response format.
Required ACL: searchAuthorizations
Your Algolia application ID.
Your Algolia API key with the necessary permissions to make the request. Permissions are controlled through access control lists (ACL) and access restrictions. The required ACL to make a request is listed in each endpoint's reference.
Body
application/json
Multi-query search request body. Results are returned in the same order as the requests.
requests
Search parameters as query string Ā· object Ā· Search parameters as object Ā· object Ā· Search parameters as query string Ā· object Ā· Search parameters as object Ā· object[]
required
Search parameters as query string.
- Search parameters as query string
- Search parameters as object
- Search parameters as query string
- Search parameters as object
Show child attributes
Show child attributes
Strategy for multiple search queries:
none. Run all queries.stopIfEnoughMatches. Run the queries one by one, stopping as soon as a query matches at least thehitsPerPagenumber of results.
Available options:
none, stopIfEnoughMatches Response
OK
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Last modified on April 30, 2026
Was this page helpful?
āI