Browse Index | Ruby API Client V1 (Deprecated)
This version of the Ruby API client has been deprecated in favor of the latest version of the Ruby API client.
browse
ACL
index.browse({ query: String, // + any browseParameters })
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
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.
Examples
Browse an index (recommended way)
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:
|
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 |
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. |