Much like Rack and other HTTP libraries, Thinking Sphinx’s searches are constructed and processed by a set of middleware. They take the provided search parameters, generate a query that Sphinx understands, makes the search request, and then translate the resulting values back into ActiveRecord instances.
Each middleware must be a class that is initialized with an app object, has an instance method call which accepts an array of search contexts, and that method should then invoke app.call(contexts) to continue the chain.
To add custom middleware into the mix, you can either do this in an initializer so it affects all searches:
Or, you can specify a custom middleware stack on a per-search basis:
The best place to understand the existing set of middleware is by reading the source code.