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
Could anyone give an example to use with Django/Postgres native Full Text Search engine? #1039
Comments
Hi @gotexis. django-filter basically does two things:
When there isn't a
If you can generalize the query, writing a custom from django.contrib.postgres.search import SearchQuery, SearchVector
from djanog_filters import FilterSet, CharFilter
class F(FilterSet):
# The model `field_name` is the field you want to search on and is passed to your `method`.
# The `method` argument is the name of the method to call to perform filtering.
search = CharFilter(field_name='body_text', method='search_fulltext')
def search_fulltext(self, queryset, field_name, value):
return queryset \
.annotate(search=SearchVector(field_name)) \
.filter(search=SearchQuery(value)) |
Wow thanks for your help @rpkilby, please give me some more days to digest this code... Right now I am banging my heads with graphene-django which integrates with django-filters. I hope to (ideally) implement this with GraphQL |
Note that there may be some issues with how graphene-django wraps django-filter. e.g.,see #927 |
@rpkilby Yes sir One of the most recent one, also related to django-filter, is their DjangoFilterConnectionField doesn't work with prefetching, resulting in tons of queries. I have been failing to debug it, I wonder if you have any experience to share :) |
Just stumbled on this issue when searching how to use django-filter with Postgres Full Text search. Since the issue is already tagged Documentation should we add a how to guide on the approach mentioned by @rpkilby in the sub-section of the doc (I can take that part up) |
Something in the Tips section would be great. https://django-filter.readthedocs.io/en/stable/guide/tips.html |
Cool, will create a PR soon for this. 😄 |
Totally noob here....
https://docs.djangoproject.com/en/2.1/ref/contrib/postgres/search/#postgresql-fts-search-configuration
The text was updated successfully, but these errors were encountered: