Hello there,
I am using a MultiSearcher to search in two indices. I want to limit the results by using Facets.
This works!
Additionally, I wan to use a search text from a search bar to filter again the results. E. g. I want to type a specific word which is contained in the title attribute of the object that should be fetched. This doesn’t work.
My code looks like this:
class HomeCollectionView: AbstractHomeView, HitsController {
public weak var hitsSource: HitsInteractor<Hit<JSON>>?
// START UI COMPONENTS
var challengeCollectionView:UICollectionView?
// END UI COMPONENTS
// START variables for interacting with the algolia server
var multiIndexSearcher: MultiSearcher?
var tournamentHitsInteractor = HitsInteractor<Hit<JSON>>()
var challengeHitsInteractor = HitsInteractor<Hit<JSON>>()
var challengeFilterState = FilterState()
var tournamentFilterState = FilterState()
// END variable for interacting with the algolia server
override init(frame: CGRect) {
super.init(frame: frame)
...
setupInstantSearchSettings()
searchChallengesAndTournaments()
}
private func setupInstantSearchSettings() {
multiIndexSearcher = .init(appID: ApplicationID(rawValue: APPID), apiKey: APIKey(rawValue: APIKEY))
let challengeSearcher = multiIndexSearcher!.addHitsSearcher(indexName: "challenges")
challengeFilterState = AlgoliaSearch.filterChallenge(filterSelections: filterSelections)
challengeHitsInteractor.connectFilterState(challengeFilterState)
challengeHitsInteractor.connectSearcher(challengeSearcher)
let tournamentSearcher = multiIndexSearcher!.addHitsSearcher(indexName: "tournament")
tournamentFilterState = AlgoliaSearch.filterTournament(filterSelections: filterSelections)
tournamentHitsInteractor.connectFilterState(tournamentFilterState)
tournamentHitsInteractor.connectSearcher(tournamentSearcher)
challengeHitsInteractor.connectController(self)
tournamentHitsInteractor.connectController(self)
}
private func searchChallengesAndTournaments() {
activityView.isHidden = false
print("Search text :" + searchBarController.searchBar.text!)
multiIndexSearcher?.query = searchBarController.searchBar.text!
multiIndexSearcher!.search()
}
Any ideas why
multiIndexSearcher?.query = searchBarController.searchBar.text!
is not affecting the result at all?
Thanks!