如何在 Algolia 中显示超过 1000 条记录 instantsearch.js

How to show more than 1000 records in Algolia instantsearch.js

我在项目中使用 Algolia 和 instantsearch.js 进行搜索并显示其中的类别和内容(类别页面和搜索页面由 Algolia 提供支持)。我们正在使用 instantsearch.js v1 来自 cdn。

我们的主要问题是搜索没有提供超过 1000 条我们需要的记录。

据我理解正确,browse() 方法提供了更多结果,但它在 instantsearch.js 中不可用。

此外,在阅读文档后,我发现有一个名为 paginationLimitedTo 的新选项,它允许显示超过 1000 条记录:

https://www.algolia.com/doc/rest-api/search/#paginationlimitedto

因此,设置此项将允许显示超过 1000 条记录。

你能帮我吗,我应该如何获得超过1000条记录,或者如果它达到我们的目标,我们如何在instantsearch.js中设置这个paginationLimitedTo属性?如果我暂时需要构建或编辑 instantsearch.js,我可以。

提前致谢,

为了更改 paginationLimitedTo 的值,您需要创建自定义 client 对象,然后通过调用 client.initIndex(indexName) 获取您的 index,然后然后调用

更改设置
index.setSettings({
  paginationLimitedTo: 1000
});

您可以在文档 here 中查看相关指南。

另外,请记住以下几点:

We recommend keeping the default value to guarantee excellent performance. Increasing the pagination limit will have a direct impact on the performance of search queries. A too high value will also make it very easy for anyone to retrieve (“scrape”) your entire dataset.