Browse Index
browse
ACL
$index->browseObjects() $index->browseObjects([ // All the following parameters are optional 'query' => string, // + any browseParameters // + any requestOptions ])
About this method
We released a new version of the PHP API client in public beta. Read the beta documentation for more information.
We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.
We released a new version of the Java API client in public beta. Read the beta documentation for more information.
You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.
You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.
Get all records from an index.
You can use the browse method to get records from an index without pagination, for example, to export your index as a backup. To export all records, use an empty query.
Use browse
instead of search
when exporting records from your index, when ranking, or analytics, isn’t important.
The Analytics API doesn’t collect data when using browse
.
Don’t use this method for building a search UI.
Use search
instead.
You can’t export your indices from the Algolia dashboard, only your index settings, synonyms and Rules. See Export and import your indices for more information.
Ranking
Results are ranked by attributes and custom ranking.
For better performance, there is no ranking for:
- distinct
- typo-tolerance
- number of matched words
- proximity
- geo distance
Reduce response size
If you don’t need all attributes, you can reduce the size of the browse
response.
Use the attributesToRetrieve
parameter to declare which attributes you want to retrieve.
Examples
Read the Algolia CLI documentation for more information.
To see a complete app, including all import and setup instructions, go to Install the .NET API client.
To see a complete app, including all import and setup instructions, go to Install the Go API client.
To see a complete app, including all import and setup instructions, go to Install the Java API client.
To see a complete app, including all import and setup instructions, go to Install the Kotlin API client.
To see a complete app, including all import and setup instructions, go to Install the Scala API client.
To see a complete app, including all import and setup instructions, go to Install the Swift API client.
Get all records from an index
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
require_once __DIR__."/vendor/autoload.php";
use Algolia\AlgoliaSearch\SearchClient;
// Use an API key with `browse` ACL
$client = SearchClient::create(
'YourApplicationID', 'YourAPIKey'
);
$index = $client->initIndex('indexName');
// Get all records
$records = $index->browseObjects();
foreach ($records as $hit) {
var_dump($hit);
}
Get all records with only a few attributes
The objectID
attribute is always retrieved.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
require_once __DIR__."/vendor/autoload.php";
use Algolia\AlgoliaSearch\SearchClient;
// Use an API key with `browse` ACL
$client = SearchClient::create(
'YourApplicationID', 'YourAPIKey'
);
$index = $client->initIndex('indexName');
// Get all records, retrieve only `title` and `content` attributes
$records = $index->browseObjects(
['query' => '', 'attributesToRetrieve' => [ 'title', 'content' ]]
);
foreach ($records as $hit) {
var_dump($hit);
}
Parameters
query
|
type: string
Required
Search query. Accepts every character and every character entered will be used in the search. Use an empty query to fetch all objects. |
browseParameters
|
type: key/value mapping
default: No browse parameters
Optional
Compatible search parameters. For example:
When using the
When using the |
requestOptions
|
type: key/value mapping
default: No request options
Optional
A mapping of |
Response
This section shows the JSON response returned by the API. Since each language encapsulates this response inside objects specific to that language and/or implementation, the actual type in your language might differ from what’s written here. You can view the response in the logs (using the getLogs
method).
JSON format
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"hits": [
{
"firstname": "Jimmie",
"lastname": "Barninger",
"objectID": "433"
}
],
"processingTimeMS": 7,
"query": "",
"params": "filters=level%3D20",
"cursor": "ARJmaWx0ZXJzPWxldmVsJTNEMjABARoGODA4OTIzvwgAgICAgICAgICAAQ=="
}
hits
|
list
Retrieved records. |
cursor
|
string
A cursor to retrieve the next chunk of objects. If absent, it means that the end of the index has been reached. |
params
|
string
URL-encoded search parameters used to filter the results. |
query
|
string
Query text used to filter the results. |
processingTimeMS
|
integer
Time that the server took to process the request, in milliseconds. This does not include network time. |
nbHits
|
integer
Number of objects in the index. Present only when the query is empty and the browse is not filtered. |
page
|
integer
Index of the current page (zero-based). Present only when the query is empty and the browse is not filtered. |
hitsPerPage
|
integer
The maximum number of hits returned per page. Present only when the query is empty and the browse is not filtered. |
nbPages
|
integer
The number of returned pages. Calculation is based on total number of hits ( Present only when the query is empty and the browse is not filtered. |