Algolia 浏览函数使用 Javascript 返回最多 1000 条记录
Algolia browse function returning max 1000 records using Javascript
我正在使用 algolia javascript api 使用浏览功能检索索引中的所有记录,但它仍然返回 1000 条记录。这是我的代码:
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);
});
}
实际上,browse
在第一次调用时 return 不会超过 1000 个元素。但是,响应包含一个 cursor
,您可以使用它通过 browseFrom
函数访问下一个元素。
但是,以前的方法有点手动。您可能想改用 browseAll
函数,它可以让您按顺序访问所有元素。
您可以在 README of the JS client (also available in the Algolia documentation).
中找到有关所有 browse*
函数的更多信息
我正在使用 algolia javascript api 使用浏览功能检索索引中的所有记录,但它仍然返回 1000 条记录。这是我的代码:
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);
});
}
实际上,browse
在第一次调用时 return 不会超过 1000 个元素。但是,响应包含一个 cursor
,您可以使用它通过 browseFrom
函数访问下一个元素。
但是,以前的方法有点手动。您可能想改用 browseAll
函数,它可以让您按顺序访问所有元素。
您可以在 README of the JS client (also available in the Algolia documentation).
中找到有关所有browse*
函数的更多信息