In my system, items (they are like blog posts), are published often.
In the main page I list 20 items, and there is a Load More button at the bottom, which will take the next 20 items. If I wait a while, there will be new blog posts in elastic, so If I click Load More, it will take the 20 items from 20 to 40, but there are new ones so it returns some items repeated.
The question is: how could I part from the last item published to paginate and get the next 20 items from that one? Like ignoring there are new items
I thought about making a query first to get the position (if there is a way to know the position of a specific item in a query) but it would be making the query twice.
I found the solution for this kind of cursor based pagination in elasticsearch:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html
[EDIT]
This is what in the end worked for me
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
Related
I am currently building a calendar schedule view feature, where I have Month title as Header and the days as the items. I am currently fetching calendar event of about 6 weeks. which if the data is not present or so, it would still cover up the page and I can use onScrollEnd to query more data via useQuery.
But, I am trying to optimize my calendar feature and querying 6 weeks worth of events would not be ideal and would take time to load. thus, I was trying to find a way, where, if I can query let's say 1 week worth of data, if that does not have enough data (like 1-2 events) to cover the screen (for user to invoke onScrollEnd), then query next batch and so on and at the end wrapping the container with memo in order to help boost the load speed and lazy load data as required. Any idea how would this be possible?
I have looked at various examples of lazy loading such as:
https://snack.expo.dev/#johnborges/044274
etc, but my problem is that in these code examples, they do not cover the possibility of first or second batch/ page to have less data and querying for next page automatically.
I also thought of using FlatList nested with SectionList, but ended with conclusion that it would not be possible and data would be rendered twice.
What I want to happen:
<Schedule> --> component
render → Coordinate which Month in the SectionList should paginate through the events
<SectionList>
onEndReached → create more months
<Month>
<FlatList>
render → <Event />
onEndReached → fetch more events
<FlatList>
</Month>
</SectionList>
<Schedule>
So there are two "onEndReached" triggers, one to create more months when the user scrolls down the entire page and a second to get more events, when the user scrolls down the current month.
The Month component should just load 1 weeks worth of events at a time and paginate as the user is scrolling.. I somehow need some way to figure out that if the current week does not have enough data to cover the screen then query more data, and so one as always show the full page... Any help/ ideas would be appreciated. Thanks :).
I would try to measure the y position of the last element. If the y position is not close enough to the bottom, fetch more items. Store the previous fetch in the state. Add to that state the new fetch.
I've used Couch CMS to create a blog page with index of articles.
I've used Couch for blog systems before and the blog index item always displays underneath each other. However, this time they must display next to each other. I've tried so many things, but the index items remains under each other oppose to next to each other. The website is based on bootstrap, but the columns just keep on stacking on top of each other.
Can someone please help?
URL: https://legacyeb.co.za/news.php
Solved. Just make sure the couch page open and page close tags are in the correct place.
Everything in between the tags gets repeated with the blog index.
I am implementing an activity feed similar to facebook or twitter's. I fetch newsfeed items in batches of x(I use RelayJS, x is the pagesize of connections). However, it may so happen that due to eager loading in the List View a lot of items are fetched for the news feed but the user doesn't scroll to the end to view them. How can I determine what news feed items a user has really seen so that I don't repeat them and only show the newer ones and the ones down below that were fetched but not shown to the user when he refreshes or opens the app next time? The easier solution is to discard all the x items that had been fetched as seen.
How is this info stored? A table of numUsers X numItems with booleans? A set of such items?
It depends a lot on your implementation. The most simple one would be return to the user only the information generated after their last login.
Now, if you want to actually keep track of the information that was actually seen by the user then I guess that is a lot more complex. Like storing every item ID and a flag to check if the user has seen it.
Then you can make a clean up on app close that will mark that very first item that you need to show them that they haven't seen. For example:
1 Not Seen
2 Not Seen
3 Seen
4 Not Seen
5 Not Seen
6 Seen
7 Seen
8 Seen
9 Seen
Upon closing the app, you store that you need to show them starting on the ID 5.
I have a requirement where I query all the records and push it to array. And since I have about 2000 records to display, it takes more time. So I would like to implement infinite scroll. But I have filter feature along with this. So how can I show all records on scroll initially and show filtered records on scroll when search box contains search term? Pls help.
Thanks in Advance!
This is a slightly more complicated task since the built in angular filter requires all the elements to be in a local array before being able to filter. So you cannot use it, and must move the task of filtering to the server, for example using the sql %like% query.
You need to reuse both the array of records, and the pagination component. So there are 2 use cases:
User is viewing unfiltered list
User has entered a valid search query and is viewing a filtered list
When user is viewing the unfiltered list, you are querying the API endpoint ex:
server.com/api/records?page=page_number
When the user is viewing a filtered list, you are querying the API endpoint ex:
server.com/api/records?page=page_number&query=mysearchquery
So the entire task becomes:
User is viewing unfiltered list
User enters a search term in the search box
Use a debounce to check the input query for validation, ex: length > 4
Front end clears entire list of records, and reset any pagination state
Pagination now occuring on the filtered list
When a user clears the search box:
Clear the list of filtered records and reset pagination state
Begin paginating the unfiltered list once again
If you any specific questions about any part of the process, I'd be happy to update my answer.
hope someone can help me with this question.
I have an entity which contains a start time (let's say 15 o'clock) and an end time (let's say 16
o'clock). It also contains the date (let's say today^^).
So my query returns all data of today, but I only want to show the data between 15 and 16 o'clock.
Do I need to set a $timeout for each object? Or is it possible to automatically call a method called shouldShowData which used in ng-show?
Basically I have a list of objects and want to show single object just on a specific time of the day.
EDIT
Imagine that the screen is shown in a public place and displays different news at different time (morning news, evening news, ...) and should automatically update when the specific news should be displayed based on it's start and end time. It can't be updated manually with a refresh button for example.
Great to here from you :)
I have found similar problem and solution for it here
All you need is to wrap this into $filter and use on ng-repeat.