Adding custom params to query

88 views
Skip to first unread message

Joe K

unread,
Feb 23, 2010, 2:14:20 PM2/23/10
to django-haystack
I'm using the Solr backend and would like to pass some solr-specific
params through. Not params that are included in the query itself, but
rather params that are passed in the query string sent to the solr
server.

It looks like with raw_search, I can get something like:

...q=query {lat: 10, long: 20, qt: geo, radius: 20}...

What I want/need is a way to get instead:

...q=query&lat=10&log=20&qt=geo&radius=20...

So...is there currently a way to do this? If not, does anyone have
ideas for how to approach this? I don't mind modifying Haystack and/
or the Solr backend if need be, and submitting a patch back. It seems
that this would be something useful across all backends.

Thanks for your help.

Joe

Joe Kueser

unread,
Feb 23, 2010, 4:28:52 PM2/23/10
to django-haystack
Here's what I came up with, based pretty extensively on xgldm's JTeam spatial search patch.

What this does is give you the capability to add raw params to your query.  It's a straight pass-through, dumb as a rock, so if you use it you should be careful.

Your query for, say, a localSolr query, might look like this:

SearchQuerySet().raw_params(lat=lat, long=long, qt='geo', radius=25).filter(content=query)

Let me know if you have any questions/suggestions/putdowns, etc.

Thanks.

Joe

adds_raw_parameter_capabilities.patch

Joe K

unread,
Feb 23, 2010, 4:35:10 PM2/23/10
to django-haystack
Ok, so apparently I can't actually attach anything. I guess if you
want the patch, let me know ;-)

Daniel Lindsley

unread,
Feb 24, 2010, 3:05:04 AM2/24/10
to django-...@googlegroups.com
Joe,


The patch was attached and I can view it no problem. I'm hesitant
to go ahead with that patch because I'm not sure it really applies to
all of the backends. There's not much you could pass to Whoosh to
alter the query further. There might be a use case with Xapian, though
again I'm not sure. Otherwise, your patch itself is what I would do in
your circumstances.

Beyond that, geo support is something I'm working on and hope to
have something meaningful done soon. It'll actually end up looking
somewhat similar to your patch, though hopefully with a bit more
support for the other options available.


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.
>
>

Reply all
Reply to author
Forward
0 new messages