Hello algolia community,
merry christmas to all of you. All the best for you and for your families.
I have an issue with fetching the latest search result that is added to an index. Basically, I just want to refresh the same search query manually to receive the last added results. This can be either one new result or multiple ones.
I observed one thing. After I was sure that a new search result was added, I refreshed my collection view to get the updated entries in the index.
In the numberOfItemsInSection delegate method, I printed out the number of hits:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
print(hitsSource?.numberOfHits())
... }
First, I received the updated number like it is supposed to be:
2020-12-24T13:42:41+0100 info com.algolia.InstantSearchCore : InstantSearch.SingleIndexSearcher: received results - index: challenges query: “” hits count: 16 in 1ms
Optional(16)
But then the
func reload() {
challengeCollectionView?.reloadData()
}
was called and after that, I got the previous number of hits again.
2020-12-24T13:42:49+0100 info com.algolia.InstantSearchCore : InstantSearch.SingleIndexSearcher: received results - index: challenges query: “” hits count: 16 in 1ms
Optional(15)
I know, we can use observers to check if a new search result is added but I want to trigger that check manually. What would be the best way to do it?