A good django search app? — How to perform fuzzy search with Haystack?
I'm using django-haystack at the moment with apache-solr as the backend.
Problem is I cannot get the app to perform the search functionality I'm looking for
Searching for sub-parts in a word
开发者_JS百科
eg. Searching for "buntu" does not give me "ubuntu"
Searching for similar words
eg. Searching for "ubantu" would give "ubuntu"
Any help would be very much appreciated.
This is really about how you pass the query back to Haystack (and therefore to Solr). You can do a 'fuzzy' search in Solr/Lucene by using a ~
after the word:
ubuntu~
would return both buntu
and ubantu
. See the Lucene documentation on this.
How you pass this through via Haystack depends on how you're using it at the moment. Assuming you're using the default SearchForm, the best thing would be to either override the form's clean_q
method to add the tilde on the end of every word in the search results, or override the search
method to do the same thing there before passing it to the SearchQuerySet.
精彩评论