Fix group filter to use OR semantics for space separated terms#15350
Fix group filter to use OR semantics for space separated terms#15350calixtus merged 35 commits intoJabRef:mainfrom
Conversation
When filtering groups in the side pane, typing multiple space-separated words (e.g. 'machine learning') now shows groups containing ANY of the words instead of requiring ALL words to be present. Implemented by reusing the existing Search.g4 ANTLR grammar. A new GroupNameFilterVisitor evaluates the parse tree against the group name string directly, without Lucene. The key change is using anyMatch (OR) instead of allMatch (AND) for implicit space-separated bare terms. Complex expressions with parentheses and NOT continue to use AND between top-level parts. Explicit AND, OR, NOT and parentheses continue to work as expected. Closes JabRef#12721
Review Summary by QodoImplement OR semantics for group filter with advanced query support
WalkthroughsDescription• Implement OR semantics for space-separated group filter terms • Reuse existing Search.g4 ANTLR grammar for advanced query support • Support explicit AND, OR, NOT operators and parentheses • Add comprehensive test coverage for filter behavior Diagramflowchart LR
A["Group Filter Input"] --> B["SearchQuery Parser"]
B --> C["GroupNameFilterVisitor"]
C --> D["OR for space-separated terms"]
C --> E["AND/OR/NOT operators"]
C --> F["Parentheses support"]
D --> G["Match Result"]
E --> G
F --> G
File Changes1. jabgui/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
This PR updates JabRef’s Groups side-pane filter to treat space-separated terms as an OR search (matching any typed word), while leveraging the existing Search.g4 grammar so that explicit boolean operators (AND, OR, NOT) and parentheses can be used in the filter input.
Changes:
- Added
GroupNameFilterVisitorto evaluateSearch.g4parse trees against group display names with OR semantics for implicit whitespace-separated terms. - Updated
GroupNodeViewModel#isMatchedByto parse and evaluate filter input viaSearchQuery.getStartContext(...), with a fallback to plaincontainsIgnoreCaseon parse errors. - Added GUI-level JUnit tests covering OR/AND/OR/NOT/parentheses behavior and updated
CHANGELOG.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
jablib/src/main/java/org/jabref/logic/search/query/GroupNameFilterVisitor.java |
New visitor implementing group-name matching based on Search.g4, with modified implicit-whitespace behavior. |
jabgui/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java |
Routes group filter matching through the new ANTLR-based parser/visitor with a malformed-query fallback. |
jabgui/src/test/java/org/jabref/gui/groups/GroupNodeViewModelFilterTest.java |
Adds tests for the new filter semantics and operator handling. |
CHANGELOG.md |
Documents the user-visible change in group filtering behavior. |
You can also share your feedback on Copilot code review. Take the survey.
jabgui/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java
Outdated
Show resolved
Hide resolved
|
|
||
| @Test | ||
| void malformedQueryFallsBackToContains() { | ||
| assertTrue(matches("test group", "test")); |
jablib/src/main/java/org/jabref/logic/search/query/GroupNameFilterVisitor.java
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/search/query/GroupNameFilterVisitor.java
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/search/query/GroupNameFilterVisitor.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jabgui/src/test/java/org/jabref/gui/groups/GroupNodeViewModelFilterTest.java
Outdated
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/search/query/GroupNameFilterVisitor.java
Outdated
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/search/query/GroupNameFilterVisitor.java
Show resolved
Hide resolved
jablib/src/main/java/org/jabref/logic/search/query/GroupNameFilterVisitor.java
Show resolved
Hide resolved
…expanded CHANGELOG to address all functionalities
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Please add disclosures on wherever AI has been used in this PR. |
jabgui/src/test/java/org/jabref/gui/groups/GroupNodeViewModelFilterTest.java
Outdated
Show resolved
Hide resolved
jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…com/NishantDG-SST/jabref into fix-group-filter-or-semantics-12721
This comment has been minimized.
This comment has been minimized.
✅ All tests passed ✅🏷️ Commit: 1ad23ed Learn more about TestLens at testlens.app. |
Related issues and pull requests
Closes #12721
PR Description
The group filter in the side pane previously required ALL typed words to appear in a group name, so typing machine learning would hide "Deep Learning" even though it contains "learning". This fix changes the behavior to OR-any matching word is enough. It reuses the existing Search.g4 ANTLR grammar for parsing So explicit AND, OR, NOT, and parentheses also work in the filter box.
Steps to test
Before

After

Before
After
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)AI Usage