Hello guys,
I am trying to fetch data from a particular index using a filter to limit the results. When I check the objects manually on the UI, I can see that according to my filter, I should get two results.
Whenever I start my app and try to fetch those objects, it works as expected.
When I try to fetch objects from the same index using the same filter query but different values, I get different objects but again the ones which are expected.
Now here comes the thing. After executing the second query I try to trigger the original first one and I expect to get two objects (as the first try). But this is not the case: Checking the logs confuses me a bit more
2021-01-05T22:04:18+0100 info com.algolia.InstantSearchCore : InstantSearch.SingleIndexSearcher: received results - index: participation query: "" hits count: 2 in 1ms
Optional(2) // OUTPUT OF hitsSource?.numberOfHits()
2021-01-05T22:04:23+0100 info com.algolia.InstantSearchCore : InstantSearch.SingleIndexSearcher: received results - index: participation query: "" hits count: 7 in 1ms
Optional(1) // OUTPUT OF hitsSource?.numberOfHits()
Optional(1) // OUTPUT OF hitsSource?.numberOfHits()
Optional(1) // OUTPUT OF hitsSource?.numberOfHits()
Here is my code:
class ChallengeContentViewController: UIViewController, HitsController {
var singleIndexHitsInteractor: HitsInteractor<JSON> = .init(showItemsOnEmptyQuery: true)
var challengeCollectionView:UICollectionView?
public weak var hitsSource: HitsInteractor<JSON>?
...
private func setupInstantSearchSettings() {
singleIndexHitsInteractor.connectController(self)
singleIndexHitsInteractor.connectSearcher(participationIndexSearcher)
}
private func searchParticipations() {
let filterState = FilterState()
filterState[or: "groupName"].add(Filter.Facet(attribute: "challengeId", stringValue:
challengeObject.id))
participationIndexSearcher.connectFilterState(filterState)
participationIndexSearcher.search()
}...
Could anyone tell me what I am doing wrong?
setupInstantSearchSettings and searchParticipations are called in viewDidLoad()
Thanks in advance!