Nifty things to do with Searx.

10 March 2020

Not too long ago I was noodling over a problem: I wanted to break up the scheduling queues in Huginn to make my fleets of agents a little more efficient when the execute.  The best way I could think of was to make some of the schedules stochastic - periodically have an agent roll some dice and depending on what comes up decide whether or not to trigger the agents downstream.  So, of course I started looking for a random number generator that would basically roll 1d10.  However, the Liquid templating language that Huginn uses internally doesn't have any function to do this and I didn't feel like bodging one together even though it would probably work well enough for my purposes.  So, off to my local Searx instance to see what I could scare up.

It was then that discovered (or re-discovered, maybe) some interesting things about the meta-search engine in question.

I started messing around in my instance's /preferences page and discovered that Searx incorporates some features that it helpfully calls answerers - search queries that basically answer simple questions for you.  Need to do some quick math?  You can do a search on one of the math functions with some arguments and get an answer.  It doesn't have all of the mathematical operators you'd expect (just addition, multiplication, minimum, maximum, and average) so it's not a fully featured calculator (I might have to file a PR to fix that) but for some quick-and-dirty math on the fly it'll be somewhat helpful.  Even more helpful is that answerers are also plugged into the Searx API so if you want to use these features in a programmatic fashion (such as through a Huginn agent) you can do so and get JSON to consume with other software.  A caveat: When I was working on this post I wasn't able to get CSV or RSS output working on any instances I tried, including my own even though they're supposedly also first-class citizens.  I've opened a Github issue about this.

Anyway, here are what the URLs would look like:






The '%20's in those URLs are URL-encoded spaces (' ').  If that's too much of a pain, though, you can use plus signs ('+') instead:

Of course, it also has a couple of random value generators - random integers, floating point numbers, SHA-256 hashes, strings, and UUIDs.






To help folks out I created a bunch of sample Huginn agents for folks to import and experiment with.

Oh, did I get around to actually using any of this myself?  Umm... not yet.