lugensa / scorched

Sunburnt offspring solr client
MIT License
27 stars 19 forks source link

Support for sending custom parameters to Solr #37

Open mlissner opened 7 years ago

mlissner commented 7 years ago

I'm not sure if there's an appetite for this, but I find it enormously useful to be able to send arbitrary parameters to Solr outside of what the API typically allows (i.e., low-level queries like what pysolr provides).

I have a function I hacked on top of sunburnt that allows me to do raw queries. For example, I can do this:

self.si.raw_query(**{'q': '*', 'caller': 'update_index'})

And that'll make a Solr request like:

http://localhost:8983/select/?q=*&caller=update_index

The main way I use this is to add a caller parameter to every request I make so that I can keep track of which ones are slow or later sort things out in the logs, but I also use it when sunburnt or lacks a parameter I need.

Any appetite for adding this into core? I can provide a PR if so.

mlissner commented 7 years ago

I've continued researching this today and there's some good news. Looks like this was added to Sunburnt towards the end of last year. Would a PR to merge this in be welcome? It's a slim and tidy little patch:

https://github.com/tow/sunburnt/pull/80

Basically, it makes it so you can do:

si.add_extras({'some': 'stuff'})

And it will simply be added to your normal chainable query.

mlissner commented 7 years ago

Sorry to keep sending messages today. Here's a gist providing the extended classes, in case other people want to just use them:

https://gist.github.com/mlissner/d1e32a5572932665c15541fdb2e2c7af