Algolia browse function returning max 1000 records using Javascript
Asked Answered
A

1

9

I am using algolia javascript api for retrieving all records in my index using browse function, but still it is returning 1000 records. Here is my code:

function load_location_list(){
var client = algoliasearch('ID', 'KEY');
var index_name = "locations_new";
var attribute_list = "*";
var index = client.initIndex(index_name);
index.browse({
    "attributesToRetrieve": attribute_list,
}).then(function search_Success(response) {
        console.log(response);
});

}

Aiguille answered 27/5, 2016 at 6:57 Comment(0)
L
1

Actually, browse doesn't return more than 1000 elements at the first call. However, the response contains a cursor that you can use to access the next elements with the browseFrom function.

However, the previous method is kind of manual. You probably want to use the browseAll function instead which lets you access all the elements sequentially.

You can find more informations about all the browse* functions in the README of the JS client (also available in the Algolia documentation).

Lenny answered 27/5, 2016 at 7:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.