Closed andrewkimjoseph closed 7 months ago
I figured how to do this.
Create a FilterGroupID
object based on the particular field you want to filter and set the operator to FilterOperator.or
:
final connectionId = const FilterGroupID("uid", FilterOperator.or)
Then, create a FilterState
object:
final _filterState = FilterState()
Then, create a function that adds the filters and connects the FilterState object to the HitsSearcher
object:
void addFiltersAndConnectFilterState() {
if (connectionUids?.isEmpty == true) {
_filterState.add(const FilterGroupID("none"), [Filter.facet("none", "none")]);
} else {
for (String uid in connectionUids!) {
_filterState.add(connectionId, [Filter.facet('uid', uid)]);
}
}
_connectionsSearcher.connectFilterState(_filterState);
}
You can call this method in initState(){};
Reply to this comment if you need any help.
I have a
List<String>
in my Dart code namedconnectionsUids
, and I wantHitsSearcher
to return only the results whoseobjectID
is inconnectionsUids
.How do I go about it?