API Reference / API Methods / Manage indices / Browse index
Required API Key: any key with the browse ACL
Method signature
$index->browseObjects()

$index->browseObjects([
  // All the following parameters are optional
  'query' => string,
  // + any browseParameters
  // + any requestOptions
])

About this method

You are currently reading the JavaScript API client v4 documentation. Check our migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

You are currently reading the Ruby API client v2 documentation. Check our migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

Get all index content without any record limit. Can be used for backups.

The browse method is an alternative to the Search index method. If you need to retrieve the full content of your index (for backup, SEO purposes or for running a script on it), you should use this method instead.

Results are ranked by attributes and custom ranking.

But for performance reasons, there is no ranking based on:

  • distinct
  • typo-tolerance
  • number of matched words
  • proximity
  • geo distance

The analytics API doesn’t collect data when using browse.

You shouldn’t use this method for building a search UI. Instead, use search along with the paginationLimitedTo setting to retrieve more than 1,000 results.

If you want to reduce the payload size of the browse response and don’t need all attributes in your records, you can use attributesToRetrieve to declare which attributes to retrieve.

Examples

This example shows how to iterate over the whole index:

1
2
3
4
5
6
// Empty query will match all records
$iterator = $index->browseObjects(['query' => '', 'filters' => 'i<42']);

foreach ($iterator as $hit) {
  var_dump($hit);
}

Retrieve only certain attributes when browsing

This example shows how to iterate over the whole index and only retrieve certain attributes:

1
2
3
4
5
6
// Empty query will match all records
$iterator = $index->browseObjects(['query' => '', 'attributesToRetrieve' => [ 'title', 'content' ]]);

foreach ($iterator as $hit) {
  var_dump($hit);
}

Browse an index and send extra HTTP headers

1
2
3
4
5
6
7
8
9
10
11
$searchParameters = [];

$iterator = $index->browseObjects([
  'query' => '', // Empty query will match all records
  'filters' => 'i<42',
  'X-Forwarded-For' => '94.228.178.246'
]);

foreach ($iterator as $hit) {
  var_dump($hit);
}

Parameters

query
type: string
Required

Query to search. Accepts every character and every character entered will be used in the search.

Empty query can be used to fetch all records.

browseParameters
type: key/value mapping
default: No browse parameters
Optional

Browse compatible search parameters.

Can contain any of the search parameters. Some useful ones for browse include:

There are certain search parameters the engine overrides:

requestOptions
type: key/value mapping
default: No request options
Optional

A mapping of requestOptions to send along with the query.

Response

In this section we document the JSON response returned by the API. Each language will encapsulate this response inside objects specific to the language and/or the implementation. So the actual type in your language might differ from what is documented.

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 data. Used with browseFrom. 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 (nbHits) divided by the number of hits per page (hitsPerPage), rounded to the nearest highest integer.

Present only when the query is empty and the browse is not filtered.

Did you find this page helpful?