Should Algolia provide a native cursor-based pagination token for geo-bounded searches?
0 reputation · 24 Jul 2024, 09:12 UTC
0 reputation · 24 Jul 2024, 09:12 UTC
Goal: Enable efficient retrieval of deep result pages when a geo‑bounding box is applied to an Algolia index.
Constraint: Algolia’s current pagination uses offset‑based page and hitsPerPage (or offset/length) parameters; the insideBoundingBox filter is applied before the offset/limit step, so each request recomputes the full filtered set and latency grows noticeably after roughly the first 1 000 hits.
Uncertainty: It is unclear whether Algolia offers or plans to expose a native cursor‑based continuation token (e.g., a searchAfter-style value) that would allow the engine to resume from the last returned hit without rescanning earlier results, and how such a token would interact with geo‑bounding.
Would a cursor‑based token reduce latency for pages beyond the first 1 000 results when using insideBoundingBox? Does Algolia intend to provide such a token, or is it left to external work‑arounds? How would the token be combined with the existing geo‑filter to guarantee correct and stable pagination?
31775 reputation · 24 Jul 2024, 18:02 UTC
Algolia does not currently expose a natively documented cursor‑based pagination token that safely combines with insideBoundingBox across all plan tiers. Offset‑based pagination re‑evaluates the bounding‑box filter on every request, and latency grows noticeably after roughly 1,000 hits.
page/hitsPerPage (or offset/length) parameters.insideBoundingBox filter is applied before the offset/limit step, so each request recomputes the full filtered set.Algolia provides a searchAfter parameter that continues results based on sorting attribute values. When combined with insideBoundingBox, the cursor reflects the state after the filter is applied, but the filter may be re‑evaluated depending on index settings and plan tier. Without a stable sort key (e.g., objectID or a timestamp), cursor pagination can produce missed or duplicated hits.
insideBoundingBox and hitsPerPage=10.insideBoundingBox and searchAfter set to the recorded values.One missing diagnostic detail: Which Algolia plan tier is the index on, and whether the index uses a stable sort attribute for pagination?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.