Skip to content

SearchFilter with unaccent #7733

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api-guide/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ The search behavior may be restricted by prepending various characters to the `s
* '=' Exact matches.
* '@' Full-text search. (Currently only supported Django's [PostgreSQL backend](https://docs.djangoproject.com/en/dev/ref/contrib/postgres/search/).)
* '$' Regex search.
* '&' Accent-insensitive search. (Currently only supported Django's [PostgreSQL backend](https://docs.djangoproject.com/en/dev/ref/contrib/postgres/lookups/#unaccent).)

For example:

Expand Down
1 change: 1 addition & 0 deletions rest_framework/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SearchFilter(BaseFilterBackend):
'=': 'iexact',
'@': 'search',
'$': 'iregex',
'&': 'unaccent',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add relevant test for this search feature? or they are already covered?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@auvipy hey! echoing a bit what I mentioned last year:
This feature is only for Django's PostgreSQL backend, which does not include tests in this repo.
Adding tests could be more complex than the scope of this PR, I think it's a perfectly valid issue to open, but would not block this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
search_title = _('Search')
search_description = _('A search term.')
Expand Down