views:

143

answers:

1

Hi folk,

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

  1. Searching for sub-parts in a word

    eg. Searching for "buntu" does not give me "ubuntu"

  2. Searching for similar words

    eg. Searching for "ubantu" would give "ubuntu"


Any help would be very much appreciated.

+4  A: 

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.

Daniel Roseman
this solution only works with solr isn't it ?
dzen