Your browser is no longer supported! Please upgrade your web browser now.

Thebes: A New, Minimal Sphinx Gem for Rails

Recently, we’ve been sharing a lot of technical lessons from building our new Help Center and in upgrading Harvest to Rails 3. The gem Harvest is releasing today, Thebes, is at the intersection of both projects.

Thebes is a wrapper around Sphinx, the search engine we use on most of our projects. Thebes differs from other solutions by staying as far away from your Rails code as possible. Instead of hiding the Sphinx configuration file behind a domain-specific language, this library assumes you will write Sphinx config files by hand. In Thebes, you edit an ERB template of your Sphinx configuration and populate it with variables at generation time. For developers needing the most flexible or fastest solution possible, this is a great way to work with Sphinx.

4 Benefits of Using Thebes

Thebes has a unique set of priorities compared to most Sphinx solutions. We’re less concerned with making Sphinx easy, and more concerned with giving you the most flexibility possible. That gives Thebes a powerful feature set.

  • Thebes can use SphinxQL. SphinxQL is the next-generation language for querying and managing Sphinx indexes. The language is mostly MySQL compatible, and the wrapper in Thebes is a very thin layer on top of the Ruby Mysql2 gem. SphinxQL still has some serious bugs, but is already faster than Sphinx’s native protocol and being used for the next-generation features of Sphinx.
  • Thebes can generate multiple Sphinx config files, and for multiple configurations. If you specify multiple files and configurations in config/sphinx.yml, your generated Sphinx config files can have unique settings. For devs who need to cluster Sphinx or have specific architecture needs, this is a great solution. The servers used by a given app instance are configured separately in config/sphinx_server.yml.
  • Thebes makes it explicit how you interact with Sphinx and your data store. If you need to optimize searches for speed, you’ll want to do things differently than any of the other Rails-Sphinx integrations do them. Thebes doesn’t provide any code for fetching results from your datastore, so you can choose how it should be done.
  • Thebes is built on Rails 3. Thebes is ready for you to use with Rails 3 today. We had used ThinkingSphinx for most projects before creating Thebes, but the project has a lot of complexity and ties to ActiveRecord 2.x code. Consequently, the porting of TS to Rails 3 isn’t turning out to be the smooth road we hoped for.

We’ve migrated several codebases away from ThinkingSphinx and onto Thebes internally and we’re looking forward to working with it more in the future. It’s worth remembering that Thebes is designed for minimal intrusion into your Rails code, and it won’t be the right solution for every app. Combined with Sphinx, we find it to be a great tool, and hope you do to.

We’re releasing Thebes as an open source solution on our Github account:

If you’re somebody that’s excited to roll up their sleeves to build new tools, be sure to check out our Harvest Careers page. We’re hiring smart people and would love to talk to you.

Thoughts or questions about this post? Need some help?
Get in touch →

This was posted in Behind-the-Scenes, Code, Product News.
  • Great write up! I REALLY wish this could be integrated into Harvest so I could perform searches on my data. I’ve wasted a lot of time having to go back through old invoices to see if I’ve billed out on certain things and it would be really great if there was a way to search the line items and then view list of invoices that match.

  • Hey guys, great to see another option for Sphinx (seriously – TS doesn’t fit every use case). However, it’s worth noting that TS 2.x supports Rails 3 (the code is in the rails3 branch of the repo). TS 1.x will continue to support Rails 1.2 and 2.x.

    I’ll definitely be looking into how you’re managing SphinxQL queries – it’s something I’ve been meaning to add for quite some time.

Comments have been closed for this post.
Still have questions? Contact our support team →