API Reference / API Methods / Search / Browse index
Feb. 26, 2019

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

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
  • You shouldn’t use this method for building a search UI.
  • The analytics API does not collect data from browse method usage.
  • If you need to retrieve more than 1,000 results, you should look into the paginationLimitedTo setting.

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);
}

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 except the following, which will be overridden by the engine:

  • typoTolerance will be forced to true - records matching up to 2 typos will be retrieved
  • distinct will be forced to false
  • facets will be forced to []
  • getRankingInfo will be forced to false
  • attributesToHighlight will be forced to []
  • attributesToSnippet will be forced to []
requestOptions
type: key value mapping
default: No request options
Optional

A mapping of request options 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?