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

[API] Set up "Dynamic" Search for api/v1/resources/ #22

Closed
BethanyG opened this issue Jan 7, 2020 · 9 comments
Closed

[API] Set up "Dynamic" Search for api/v1/resources/ #22

BethanyG opened this issue Jan 7, 2020 · 9 comments
Labels
enhancement New feature or request hold stale

Comments

@BethanyG
Copy link
Member

BethanyG commented Jan 7, 2020

Currently, api/v1/resources/ uses filters.SearchFilter as its filter_backend. This particular filter does a search on all fields for the requested parameters, which is not granular enough for our search needs.

As in this article: https://medium.com/better-programming/how-to-make-search-fields-dynamic-in-django-rest-framework-72922bfa1543? we need to make this api endpoint more dynamically searchable by implementing a custom filter_backend.

@BethanyG BethanyG self-assigned this Jan 7, 2020
@billglover billglover added the enhancement New feature or request label Jan 16, 2020
@BethanyG BethanyG removed their assignment Jan 20, 2020
@BethanyG
Copy link
Member Author

BethanyG commented Feb 14, 2020

There is an additional twist for this now that we are using a generic relation for Tags through taggit.

Generic Relations

Generic Relations Tutorial

Django-filter (not sure this will help - needs more investigation)

DRF Search Filter

Real Python on Polymorphism in Django & Generic Keys

@BethanyG BethanyG changed the title Set up "Dynamic" Search for api/v1/resources/ [API] Set up "Dynamic" Search for api/v1/resources/ Feb 19, 2020
@BethanyG BethanyG self-assigned this Mar 6, 2020
@BethanyG
Copy link
Member Author

BethanyG commented Mar 6, 2020

Going to try and take a shot at this at some point soon, but would welcome some collaborators.

@BethanyG BethanyG added the help wanted Extra attention is needed label Mar 6, 2020
@billglover
Copy link
Contributor

Am I right in understanding that the aim of this is to allow the user to specify which fields they'd like their search query matched against as part of the search request and that without this the default is to search all fields?

@BethanyG
Copy link
Member Author

BethanyG commented Mar 7, 2020

That is correct.

The current implementation is a "default" implementation of the DRF Filter Backend, which really does nothing more than filter the all resources queryset() down to the terms "searched on" ...if that makes sense.

So searching is a simple "includes" match against the content in all fields in the resources model.

The twist is that although tags are returned as part of the resources view..they're not actually part of the resources model, and so are not included in this "default" search.

Implementing dynamic search would attempt to do two things:

  1. Allow users to specify which fields they'd match against
  2. Attempt to include tags as part of that search

But (as noted in issue #73) number 2 might need to be part of an overall strategy for a tagging endpoint.

@BethanyG
Copy link
Member Author

BethanyG commented Mar 7, 2020

Correction. We are using the DRF SearchFilter Backend - but functionally, it more or less has the same effect. Yes - we can control which fields the search runs against, but it is not a very intelligent search - and we cannot currently include tags as part of the search fields.

@BethanyG BethanyG removed their assignment Mar 8, 2020
@billglover billglover added help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Mar 8, 2020
@BethanyG BethanyG self-assigned this Mar 21, 2020
@stale
Copy link

stale bot commented Aug 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 17, 2020
@BethanyG BethanyG removed the stale label Aug 20, 2020
@BethanyG BethanyG removed their assignment Aug 23, 2020
@stale
Copy link

stale bot commented Sep 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 22, 2020
@BethanyG BethanyG added hold and removed stale help wanted Extra attention is needed labels Sep 23, 2020
@BethanyG
Copy link
Member Author

Putting this on hold for a bit while we thin through hangouts and tagging and weather or not we will be using something like haystack or something else.

@stale
Copy link

stale bot commented Oct 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 29, 2020
@stale stale bot closed this as completed Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hold stale
Projects
None yet
Development

No branches or pull requests

2 participants