algolia / algolia/algoliasearch-helper-flutter
Question: Disjunctive Filters between Numeric and Facets
- Dominant language
- Dart
- Stars
- 27
- Forks
- 21
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
We are trying to create the following query:
`status:active OR lastAttendedDate > 1700000000000`
Our code looks like this:
```dart
filterState.add(FilterGroupID.or('someGroup'), [
Filter.facet('status', "active"),
Filter.comparison('date', NumericOperator.greaterOrEquals, 170000000),
]);
```
When we look at the query parameters produced tho, we got this `status:active AND lastAttendedDate > 1700000000000`
By looking at the internal code:
```dart
String? sql(Set filterGroups) {
final groups = filterGroups.whereNot((element) => element.isEmpty);
if (groups.isEmpty) return null;
return groups.map(_sqlGroup).join(' AND ');
}
```
This function seems to be adding an `AND` between multiple-group, but in our case what is not obvious to us is why our filter is considered to be made of 2 groups, where we only have one. This seems to happen only when we use `Filter.comparison` or `Filter.range`.
Our expectation is that when we add a Disjuctive group that will be respected, but in this case it seems to be forced into a conjuctive one, why is that?
Some additional info is that all our facets are configured as `filters only` in the dashboard.
Any help?
Contributor guide
Research direction
Start by tracing filterState.add through the shown sql(Set) function, then compare how Filter.comparison and Filter.range are grouped with facet filters. Reproduce the query using the supplied values and dashboard filters-only configuration; done means identifying why the OR group becomes conjunctive and documenting or confirming the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100