Django Haystack-Xapian search not performed with special characters and spaces

I am working on an existing Django project that uses haystack with xapian backend for a global search function. However, the search seems to fail when I perform a search with some special characters, such as ... etc. I tried, but could not find a way to fix this.

Is there a way to avoid these characters and make the search work? I am using PostgreSQL in the background. Any pointers would be very helpful.

Update: The search function uses SearchForm, and the query string is in the q field of. This is used in the code below.

sqs = self.searchqueryset.auto_query(self.cleaned_data['q'])

I tried using:

sqs = self.searchqueryset.filter(self.cleaned_data['q'])

and

sqs = self.searchqueryset.filter(content=Clean(self.cleaned_data['q']))

bad luck. I still cannot search with spaces and special characters like &.

+4
2

, Haystack, haystack.inputs.Clean , . , :

q = "amp & sand"
q_clean = haystack.inputs.Clean(q)
sqs = SearchQuerySet().filter(content=q_clean)

: http://django-haystack.readthedocs.org/en/latest/inputtypes.html#clean

+1

: () Xapian-Haystack.

, , , , Xapian-Haystack : Xapian, , , .

, "^ best-seller" : "best" "seller": "^" "^ best-seller" .

: .

, Xapian-Haystack ( Haystack), .

, , .

+1

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


All Articles