r/SoftwareEngineering • u/Dense-Studio9264 • Jan 05 '26
Help me solve the "Moving Target" problem
Hey everyone,
I’m hitting a fascinating (and frustrating) architectural debate at work regarding pagination logic on a large-scale search index (Solr/ES). I’d love to get some perspectives.
Some Context
We have millions of records of archaeological findings (and different types of events). There are two critical timestamps:
- Event Time: When the historical event actually happened (e.g., 500 BC). This is what users sort by.
- Creation Time: When the post was added to our system. This is what users filter by (e.g., "Show me things discovered in the last hour").
The Problem: (according to GPT called "Temporal Drift")
We use infinite scroll with 20-post increments. The front-end requests posts created within the "last hour" relative to now.
- User searches at 12:00 PM for posts from the last hour.
- They spend 5 minutes reading the first 20 results.
- At 12:05 PM, the infinite scroll triggers a request for "Page 2" using the same "last hour" logic.
Because the "relative window" shifted by 5 minutes, new records that were indexed while the user was reading now fall into the query range. These new records shift the offsets. If a new record has an "Event Time" that places it at the top of the list, it will be at the top of the list (Above Page 1)
The result? When the user fetches Page 2 (starting at offset 21), they completely miss the item that jumped to the top.
The Debate
We are torn between two approaches:
Option A: The "Snapshot" Approach. When the user first searches, we "lock" the anchor_time. Every pagination request uses that fixed timestamp of the first page instead of Date.now().
- Pros: Consistency. No skipped records.
- Cons: Users don't see "live" data as they scroll; they have to refresh.
Option B: The "Live Stream" Approach. Every page fetch is a fresh query against the current time.
- Pros: Truly real-time.
- Cons: The "Jumping Content" problem. It’s a UX nightmare where items disappear or duplicate across page boundaries.
My Question to You
- How do you handle pagination when the underlying filter window is moving?
- Is there a "Industry Standard" for infinite scroll on high-velocity data?
28
u/Pale_Ad_9838 Jan 05 '26
Use Option A and give the user an info that there have been added x new entries since getting the last result, allowing him to refresh the result.
4
u/Cautious_Ice_884 Jan 05 '26
Choose Option A. It is the most realistic option and the most feasible.
It really comes down to managing customer expectations, cost, and resources. Are there actually enough cost, resources, and a true need for Option B? The answer is probably "no" across the board. Realistically Option A is the route to go, especially if the customer doesn't actually need to see true live data.
You could also add in a feature to auto refresh after 10 mins or whatever is acceptable.
3
u/Significant-Leek8483 Jan 05 '26
I think twitter feed follows the first approach. You expect users to refresh and dont muddy their view by pushing content ; which is quite annoying In my opinion…
1
u/happy_hawking Jan 05 '26
You should approach this discussion from the user's PoV: what would be their preferred strategy.
Also: all sites with a feed that I know have switched from "latest first" to "most relevant first" sorting. This might be one of the reasons, why they do this.
My personal opinion: if the feed is about staying up to date about recent events by the minute, I don't care about the sort order, I care to be informed about the latest events.
Why not just attach all posts that have been added since the last refresh directly after the posts the user has already seen? This keeps them as far at the top as possible without skipping anything.
3
u/LeJoueurGazgano Jan 05 '26
Option A seems the best approach. Eventually you can fix the "last records" issue by sending regularly another request with Date.now() and display a floating card or a sticky header noticing the user new records are available and invite them to click to load them
2
u/[deleted] Jan 05 '26
A.
RAFT style baby.
1
u/cappielockie Jan 05 '26
Maybe option C: display a button 'New entries are available'. Clicking it would go back to the first page.
This makes it explicit and gives control to the user.
1
u/willalwaysbeaslacker Jan 06 '26
Assuming that changing the design to sort by create time, is not an option for stakeholders.
Also assuming the create time does display in the list for each entry somewhere to the user (it should because it’s relevant and part of their filter)
Similar to option A, anchor the date for the create time filter, such that at 12:05pm, when it gets the next batch it will still include 11am thru 12:05 as the window for the last hour.
If and only if, the next batch adds entries to the list that were newly created (after 12pm) but with event times before the most recent event time from the last batch, give some visual indication to let them know that new entries have been added, so the user knows to scroll up to find them.
Now you have to deal with an ever expanding window of time, more entries get added to the screen, and the the longer they stay on the screen, and need to help the user find what they need. This also sucks because they have to scroll past stuff they have already seen just to search for what ever is newly created, but I’m assuming the sort can’t be changed.
The create time that displays for each entry should have some indicator to the users relating to that anchored window of time for the filter. For example, if the create time is older than what would normally be considered the last hour (before 11:05), it’s de-emphasized with a visual queue like greying out the text of the time a bit. If the create time is newer than the last batch of entries retrieved (after 12pm) the it should be emphasized, like bolding the text of the create time a bit.
This can go on indefinitely with each new batch that is fetched. Entries the fall outside the current hour are de-emphasized. Only new entries with create time since the previous batch are emphasized, and the user is only notified to scroll up if there are new entries for them to find which are easy to find because of that emphasis.
If the user performs a manual refresh reset the window back to the hour.
If you are going to auto refresh my suggestion would be:
1
u/Clear-Criticism-3557 Jan 06 '26
Option A for sure.
Way too much discussion about this. Seems like the least amount of work, and no weirdness for the user.
1
u/MoussaAdam Jan 06 '26
This is a UX question, most products pick option A. not seeing live data isn't a cons, because users are already primed by other products to not expect that. if you sort by "New" on reddit, you will have to refresh to see new posts.
Take inspiration from youtube maybe: after a while they notify you that your feed is stale, and they provide a refresh button along the message so you don't have to look for it if you decide to act on that signal.
1
u/InevitableAir4620 Jan 07 '26
Option A with a small info saying something like new records available when it is.
1
u/riotinareasouthwest Mar 01 '26
There's an answer (option A + warn users about new data) which I upvoted as I think it's the best user friendly approach, but I would like to know how much alive is archeological data. Does this type of information change so often that you have to take this use case into account? If it's a rare event just go for option A maybe adding an note for the users about the searches being a snapshot done at the time the search button was clicked.
1
u/[deleted] Jan 10 '26 edited Jan 10 '26
[removed] — view removed comment
1
u/[deleted] Jan 22 '26
[removed] — view removed comment
1
u/[deleted] Jan 27 '26
[removed] — view removed comment