Skip to content

Search API

Search for records in a single index.

POST /1/indexes/{indexName}/query
{
"query": "search term",
"page": 0,
"hitsPerPage": 20,
"attributesToRetrieve": ["title", "year"],
"attributesToHighlight": ["title"],
"filters": "year > 2000",
"facets": ["genre"]
}
ParameterTypeDefaultDescription
querystring""Search query text
pageinteger0Page number (0-indexed)
hitsPerPageinteger20Number of results per page (max 1000)
attributesToRetrievestring[]["*"]Attributes to include in results
attributesToHighlightstring[]["*"]Attributes to highlight matching text
highlightPreTagstring"<em>"HTML tag before highlighted text
highlightPostTagstring"</em>"HTML tag after highlighted text
filtersstringFilter expression (Algolia filter syntax)
facetsstring[]Facets to compute counts for
facetFiltersarrayFacet-based filtering
numericFiltersarrayNumeric filtering
{
"hits": [
{
"objectID": "1",
"title": "The Matrix",
"year": 1999,
"_highlightResult": {
"title": {
"value": "The <em>Matrix</em>",
"matchLevel": "full",
"matchedWords": ["matrix"],
"fullyHighlighted": false
}
}
}
],
"nbHits": 1,
"page": 0,
"hitsPerPage": 20,
"nbPages": 1,
"processingTimeMS": 0,
"query": "matrix",
"params": "query=matrix",
"facets": {
"genre": {
"sci-fi": 1
}
}
}
FieldTypeDescription
hitsarrayArray of matching records
hits[].objectIDstringUnique record identifier
hits[]._highlightResultobjectHighlighted attributes
nbHitsintegerTotal number of matching records
pageintegerCurrent page number
hitsPerPageintegerResults per page
nbPagesintegerTotal number of pages
processingTimeMSintegerServer-side processing time in milliseconds
querystringThe query that was searched
paramsstringURL-encoded search parameters
facetsobjectFacet counts (if facets was requested)
Terminal window
curl -X POST 'http://localhost:7700/1/indexes/movies/query' \
-H 'X-Algolia-Application-Id: flapjack' \
-H 'X-Algolia-API-Key: YOUR_ADMIN_KEY' \
-H 'Content-Type: application/json' \
-d '{
"query": "matrix",
"hitsPerPage": 5,
"attributesToHighlight": ["title"],
"facets": ["genre"]
}'

Search across multiple indices in a single request. This is the endpoint that InstantSearch.js uses internally.

POST /1/indexes/*/queries
{
"requests": [
{
"indexName": "movies",
"query": "matrix",
"hitsPerPage": 5
},
{
"indexName": "actors",
"query": "keanu"
}
],
"strategy": "none"
}
ParameterTypeDescription
requestsarrayArray of search requests
requests[].indexNamestringIndex to search
requests[].querystringSearch query
requests[].*All single-index search parameters are supported
strategystring"none" (run all) or "stopIfEnoughMatches" (stop early)
{
"results": [
{
"hits": [...],
"nbHits": 1,
"page": 0,
"hitsPerPage": 20,
"processingTimeMS": 0,
"query": "matrix",
"index": "movies"
},
{
"hits": [...],
"nbHits": 3,
"page": 0,
"hitsPerPage": 20,
"processingTimeMS": 0,
"query": "keanu",
"index": "actors"
}
]
}
Terminal window
curl -X POST 'http://localhost:7700/1/indexes/*/queries' \
-H 'X-Algolia-Application-Id: flapjack' \
-H 'X-Algolia-API-Key: YOUR_ADMIN_KEY' \
-H 'Content-Type: application/json' \
-d '{
"requests": [
{"indexName": "movies", "query": "matrix"},
{"indexName": "actors", "query": "keanu"}
]
}'