-
Notifications
You must be signed in to change notification settings - Fork 772
Allow advanced search to return archived questions #6631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Allow advanced search to return archived questions #6631
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates search filtering behavior to allow advanced search to return archived questions by conditionally applying archived filters based on the search mode (simple vs. advanced).
- Added a new parameter, is_simple_search, to the get_filter methods in search and base classes.
- Updated filter logic to conditionally exclude archived questions only on simple search.
- Propagated the search mode flag down to child filters for consistent filtering behavior.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
kitsune/search/search.py | Updated get_filter signatures and filtering logic to handle archived status |
kitsune/search/base.py | Updated abstract method signature and usage of get_filter with search mode |
def get_filter(self): | ||
"""Placeholder for subclasses, should be implemented there.""" | ||
raise NotImplementedError | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed because all of the sub-classes of SumoSearch
already implement get_filter
, and in general, it's impossible to instantiate a sub-class of SumoSearch
without implementing all of its abstract methods.
# Pass the flag down to children filters | ||
return DSLQ( | ||
"bool", | ||
should=[child.get_filter() for child in self._children], | ||
minimum_should_match=1, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new lines should be removed, and the original line restored. The self._from_children("get_filter")
is necessary because it flattens the list of filters.
|
||
if not self.parse_query: | ||
# Only exclude archived documents in simple search | ||
filters.append(DSLQ("term", is_archived=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does is_archived
need to be added to the WikiDocument
in order to filter on it?
We do a test to see if we are using simple or regular/advanced search. If we determine we are using simple search, we won't show archived questions. If we are using advanced search, we will return archived questions.