One possibility is to use MySQL. By default it indexes things so that a, á, and 
À are the same thing. There are some gotchas though: you have to make sure that 
it’s using an appropriate character set for the languages you’re using. (UTF-8 
is a good choice.) There’s not a good similar solution for PostgreSQL. While it 
is possible to write a function, and create an index on that function, I 
haven’t found a way of searching on that index in Django. If anyone knows of a 
way to do it, I’d love to here it.

On Jun 1, 2012, at 11:41 AM, Kurtis Mullins wrote:

> Maybe you could just build a simple index? It'd basically be a set of 
> keywords, each with a set of matching books.
> So in your example, you'd have two keywords:
> 
> hola (with accent) -> book1, book2, etc..
> hola (without accent) -> (same as previous)
> 
> And then just write some sort of functionality to run through your data and 
> index it to a table. I can't vouch that this is the best approach - but I 
> think it'd at least solve the problem.
> 
> On Fri, Jun 1, 2012 at 1:03 PM, Joni Bekenstein <jonibekenst...@gmail.com> 
> wrote:
> I need to do a simple search ignoring some characters with accents. The idea 
> would be that "hola" matches the search term "holá".
> 
> What I'm currently doing is adding a CharField to my model to store the 
> searchable term. For example:
> 
> class Book(models.Model):
>   title = models.CharField(max_length=100)
>   searchable_title = models.CharField(max_length=100)
> 
> When I save a Book I'll replace the accented characters in title with their 
> non-accented counterparts and store the result in searchable_title. The, I'll 
> also do the same thing with the search term before actually doing the query.
> 
> I don't like this approach because if I need to add more searchable fields 
> things start getting noisy in my models.
> 
> Any ideas?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/tdIUkptWpZgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

Peter of the Norse
rahmc...@radio1190.org



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to