Unescaping query string

154 views
Skip to first unread message

Phui Hock

unread,
May 3, 2011, 6:40:28 AM5/3/11
to django-haystack
Hi,
Suppose that user keys in "author:test" and the resulting GET request
is "/search/articles/?q=author%3Atest1", how can I get Haystack to
pass 'author:test' unescaped to solr?

The following is what I get from solr's log (and the interesting bit
is q=author\:test1):
INFO: [] webapp=/solr path=/select/ params={hl.fragsize=200&fl=*
+score&start=0&q=author\:test1&wt=json&fq=django_ct:
(article.article)&hl=true&rows=0} hits=0 status=0 QTime=2

It looks to me like somewhere in Haystack escapes the query before
passing it to solr backend, but I'm seemingly lost and I couldn't
figure out where and how Haystack did it.

Daniel Lindsley

unread,
May 3, 2011, 12:52:33 PM5/3/11
to django-...@googlegroups.com
Phui,


Right now, the form is doing
``SearchQuerySet().auto_query(self.cleaned_data['q'])``, which does
the escaping. You can do
``SearchQuerySet().filter(content=self.cleaned_data['q'])`` to pass it
along unescaped, though you'd be better off doing
``SearchQuerySet().filter(author='test1')`` if you can get just the
author name from the user.


Daniel

> --
> You received this message because you are subscribed to the Google Groups "django-haystack" group.
> To post to this group, send email to django-...@googlegroups.com.
> To unsubscribe from this group, send email to django-haysta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-haystack?hl=en.
>
>

Phui Hock

unread,
May 4, 2011, 10:34:27 AM5/4/11
to django-haystack


On May 4, 12:52 am, Daniel Lindsley <polarc...@gmail.com> wrote:
> Phui,
>
>     Right now, the form is doing
> ``SearchQuerySet().auto_query(self.cleaned_data['q'])``, which does
> the escaping. You can do
> ``SearchQuerySet().filter(content=self.cleaned_data['q'])`` to pass it
> along unescaped, though you'd be better off doing
> ``SearchQuerySet().filter(author='test1')`` if you can get just the
> author name from the user.

Ah, perfect! Thanks alot!
Reply all
Reply to author
Forward
0 new messages