Good django search app? - How to perform a fuzzy search with Haystack?

I am using django-haystack at the moment with apache-solr as the backend.

The problem is that I cannot get the application to execute the search function that I am looking for

  • Search for parts in a word

    eg. Searching for "buntu" doesn't give me "ubuntu"

  • Search for similar words

    eg. Searching for "ubuntu" will give "ubuntu"


Any help would be greatly appreciated.

+4
source share
1 answer

It really is about how you pass the request back to Haystack (and therefore to Solr). You can do a fuzzy search in Solr / Lucene with ~ after the word:

 ubuntu~ 

will return both buntu and ubantu . See Lucene Documentation.

How you go through Haystack depends on how you are currently using it. Assuming you use SearchForm by default, it would be best to either override the clean_q form method to add a tilde at the end of each word in the search results, or override the search method to do the same before passing it to SearchQuerySet.

+9
source

Source: https://habr.com/ru/post/1299010/


All Articles