Skip to content

Commit dfeb312

Browse files
authored
algolia: Bump pagination limit to 4000. (#758)
For the Our415 collaboration, in one of their pages, they would like to have more than 1000 search results, which is above the default limit that Algolia sets. Algolia allows this to be increased, though mentions that there are performance tradeoffs involved, where bumping the number by a lot could slow down search results. It seems that they are looking at having up to mid 3000s, so we've agreed that 4000 is a reasonable limit to set. This can be configured via the `algoliasearch-rails` gem, with the `paginationLimitedTo` property that can be set on a index. When a resource or service gets indexed, this causes the setting to be synchrorized to Algolia. The setting is also configurable via the web admin site, but we choose to configure it in the code to ensure that there is a revision controlled source of truth to these settings. Note that this needs to be configured on both the Resource and Service models, since we do something unusual by having both models share the same Algolia index. Not updating both could result in the setting being changed as the different models are indexed.
1 parent 55dd383 commit dfeb312

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

app/models/resource.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class Resource < ActiveRecord::Base
4545
id: :algolia_id do
4646
# specify the list of attributes available for faceting
4747
attributesForFaceting Rails.configuration.x.algolia.attributes_for_faceting
48+
49+
paginationLimitedTo 4000
50+
4851
# Define attributes used to build an Algolia record
4952
add_attribute :_geoloc do
5053
if addresses&.any?

app/models/service.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class Service < ActiveRecord::Base
4040
# specify the list of attributes available for faceting
4141
attributesForFaceting Rails.configuration.x.algolia.attributes_for_faceting
4242

43+
paginationLimitedTo 4000
44+
4345
# Default has "geo" before "filters", but we need it after if we want
4446
# optional filters to have higher priority than distance.
4547
ranking %w[typo words filters geo proximity attribute exact custom]

0 commit comments

Comments
 (0)