I was able to figure this out using...
-- from django.contrib.postgres.lookups import Unaccent queryset.annotate(search_index=StrIndex(Unaccent(Lower('name')), Value(q)))Might be nice to add to the documentation here:
https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/lookups/#unaccent
On Sunday, January 5, 2020 at 11:12:45 AM UTC-8, Alex Scott wrote:
On Sunday, January 5, 2020 at 11:12:45 AM UTC-8, Alex Scott wrote:
Hi all,I just started using the Unaccent extension for Postgres and implementing queryset filters with it like:q = 'hello'queryset.filter(name__unaccent__istartswith=q) I'm now trying to annotate the queryset result with the search index:queryset.annotate(search_index=StrIndex(Lower('name'), Value(q))) That works fine by itself for unaccented text, but I'm trying to figure out a way to apply Unaccent to the name variable there, something like:queryset.annotate(search_index=StrIndex(Lower('name__ unaccent'), Value(q))) --> This has no effect, does the same as the above.orqueryset.annotate(search_index=StrIndex(Lower(Unaccent( 'name')), Value(q))) --> There doesn't seem to be an Unaccent functionIs there a way to do this currently?Thanks,Alex
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ee1d633e-366a-4d3e-832e-fe8f35fe2664%40googlegroups.com.
No comments:
Post a Comment