我正在使用InstantSearch
from Algolia
,它基本上是您配置并绑定到搜索栏(小部件)的单例。问题是在他们的演示中,InstantSearch
该类是 a Singleton
,因此不能多次实例化。但是,它可以配置多次,但随后会更改整个应用程序的配置。
InstantSearch.shared.configure(
appID: algoliaAppID,
apiKey: key,
index: algoliaUserIndex
)
他们提供的一种解决方案是多索引搜索,但在我的情况下,它是索引的聚合,而在我的情况下,它只想进行不同的隔离搜索。
对于多个索引参考:
let searcherIds = [SearcherId(index: algoliaUserIndex),
SearcherId(index: algoliaMessageSessionsIndex)]
InstantSearch.shared.configure(appID: algoliaAppID,
apiKey: key,
searcherIds: searcherIds)
所以,我的问题是: 我怎样才能有两个不同的搜索栏,每个搜索栏搜索不同的索引?