How to achieve wildcard search using haystack in django

72 views
Skip to first unread message

shaw...@gmail.com

unread,
Apr 10, 2018, 3:28:29 PM4/10/18
to Django users

I am currently working on haystack search in django. I met 2 problems, first, when I use 'Whoosh' engine, the search can only return the result that match exactly the same with my search key, for example if I type 'ABC', it cannot match 'ABCD' Secondly, how can I achieve wildcard search using haystack? For example, if I type'A*C', it can return 'ABC', 'ABCCC' 'AC' and so one. Or other method just to achieve the same result(Basically, return the result that contains the key word in same order)


Gabriel - Iulian Dumbrava

unread,
Apr 11, 2018, 9:40:11 AM4/11/18
to Django users
Please note that there are a few considerations when using wildcards.
First, there are some issues with haystack and woosh, as the one here. Wildcards work by default with autosearch, otherwise you'll have to compile the query yourself.

On the other hand, you must consider the backend haystack uses. I haven't used Whoosh recently, but I know that other backends, like solr, for example uses by default a minimum of 3 character 'groups' when generating search items, so it may also be the case that the search you are doing does not fall into any of those groups.
Reply all
Reply to author
Forward
0 new messages