MultiSearcher class abstract interface

Core component for multi-search requests and managing search sessions in Algolia Helpers.

The MultiSearcher lets you simultaneously search for hits and facet values in different indices of the same Algolia application . It instantiates and manages HitsSearcher and FacetSearcher instances internally. Once created, these searchers behave like their independently instantiated counterparts.

Create MultiSearcher

Instantiate MultiSearcher using the constructor:

final multiSearcher = MultiSearcher(
  applicationID: 'MY_APPLICATION_ID',
  apiKey: 'MY_API_KEY',
  eventTracker: Insights('MY_APPLICATION_ID', 'MY_API_KEY'),
);

Add Searchers

You can add HitsSearcher or FacetSearcher instances to the MultiSearcher using the provided methods:

final hitsSearcher = multiSearcher.addHitsSearcher(
  initialState: const SearchState(indexName: 'MY_INDEX_NAME'),
);
final facetSearcher = multiSearcher.addFacetSearcher(
  initialState: const FacetSearchState(
    facet: 'category',
    facetQuery: 'shoes',
    searchState: SearchState(
      indexName: 'MY_INDEX_NAME',
    ),
  )
);

Dispose

Call dispose to release underlying resources:

multiSearcher.dispose();
Implemented types

Constructors

MultiSearcher({required String applicationID, required String apiKey, EventTracker? eventTracker, Duration debounce = const Duration(milliseconds: 100)})
Creates a new instance of MultiSearcher using Algolia as the search service.
factory
MultiSearcher.custom(MultiSearchService searchService, EventTracker eventTracker, [Duration debounce = const Duration(milliseconds: 100)])
Creates MultiSearcher using a custom MultiSearchService and EventTracker.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
Whether this Disposable has already released its resources.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addFacetSearcher({required FacetSearchState initialState}) FacetSearcher
Adds a new FacetSearcher to the multi-searcher.
addHitsSearcher({required SearchState initialState}) HitsSearcher
Adds a new HitsSearcher to the multi-searcher.
dispose() → void
Releases this Disposable resources.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited