Skip to content
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

Allow OR filters #3914

Closed
newswangerd opened this issue Jun 8, 2023 · 6 comments · Fixed by #4270
Closed

Allow OR filters #3914

newswangerd opened this issue Jun 8, 2023 · 6 comments · Fixed by #4270

Comments

@newswangerd
Copy link
Contributor

Is your feature request related to a problem? Please describe.
We would like to include more advanced filtering options in the Automation Hub UI that allow for users to filter API results using OR lookups, for example I should be able to filter results using expressions such as name__icontains=foo OR name__icontains=bar.

Describe the solution you'd like
There are a number of possible options to consider for this:

  • ORing multiple params with the same name (eg ?name=foo&name=bar). This would break backwards compatibility with the ruby and python bindings, as the open api spec type field would change to a list type.
  • Provide a character delimited list (eg ?name=foo,bar, ?name=foo|bar). | may make more sense, as , are used for list values in other parts of the API.
  • Adding __in to the list of default lookup expressions (eg ?name__in=foo,bar). This may not work with more complex lookups like name__icontains__in=.

Additional context
The AAP team is work on unifying the UI experience across the ansible platform, and this is one capability supported by the other platform components (such as ansible controller), but is currently missing in Automation Hub

@jamestalton
Copy link

Example

Querying for name contains james or name contains john and status equals online or status equals offline.

( name = john | james ) & ( status = online | offline )

That would result in:

  • James Online
  • John Offline

Example of how PatternFly displays the filter criteria:
Screenshot 2023-06-08 at 1 44 54 PM

@lubosmj
Copy link
Member

lubosmj commented Jun 13, 2023

Attaching #2480 for completeness.

@newswangerd
Copy link
Contributor Author

adding icontains__in to the filter expressions doesn't work.

pulp_1          | django_filters.exceptions.FieldLookupError: Unsupported lookup 'icontains__in' for field 'core.Domain.name'.

@himdel
Copy link

himdel commented Jun 26, 2023

ORing same name might not work either - collection version search by tag does allow ?tags=cloud&tags=security meaning AND - and that seems like something we'd want to keep working

@jamestalton
Copy link

jamestalton commented Jul 31, 2023

Background
Ansible is moving to have more of a unified look, experience, and feel.

A big part of the user experience is the filter capabilities of the different tables with the UI.
AWX and EDA backends already support the filtering needed for the experience UXD has designed.

Example: Show jobs of job type (playbook run or workflow job) and with status (running or failed or error)
Screenshot 2023-07-31 at 11 14 28 AM

AWX QueryString example:

?or__type=system_job&or__type=workflow_job&or__status=running&or__status=failed&or__status=error

HUB needs to support the same functionality. For the backend, HUB uses Pulp, thus we need this support in Pulp.

Note: There are some use cases such as the one with labels where a customer could use an advanced filter to filter using an AND operation. Example: Instead of records with a tag of (tag1 OR tag2) we would also still need to have a way through the API to query for records with tags of (tag1 AND tag2). That would not be the default filtering, but would be available in advanced filters. The Ansible AWX backend already supports advanced filters.

We are moving forward with the work on the unified Ansible experience, with the assumption that Pulp we have this support. If that is not that case, we would love to hear about it sooner than later.

mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 11, 2023
@pulpbot pulpbot moved this from Free to take to Needs review in RH Pulp Kanban board Aug 11, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 11, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 11, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 11, 2023
@matburt
Copy link

matburt commented Aug 14, 2023

Given this commit references consistency with AWX which also uses django... we implement these filters here: https://github.com/ansible/awx/blob/devel/awx/api/filters.py

mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 15, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 16, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 16, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 17, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 17, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 17, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 21, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 22, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 23, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 23, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 24, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 24, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 24, 2023
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Aug 24, 2023
mdellweg added a commit that referenced this issue Aug 24, 2023
@pulpbot pulpbot moved this from Needs review to Done in RH Pulp Kanban board Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants