We recently open-sourced Moonstone, our JRuby wrapper around Lucene, the Java search engine toolkit. Moonstone is simple, and easy to use - it lets you put together a powerful search engine quickly. It gives you the full capabilities of Lucene, but replaces the Java-isms with a more Ruby-ish syntax. I wanted to take a quick minute to run through the basics:


    sudo jruby -S gem install moonstone
Note that if you are on Windows, drop the "sudo". Also, for the record, no one's ever tested Moonstone on Windows. But since it's all JRuby and Java, there shouldn't be any issues...

If you want the source, you can get it from automatthew's github repo.


Creating an engine requires two things: a doc_from method and an analyzer.

class SimplestEngine def doc_from(record)
doc =
doc.add_field('name', record[:name])
doc.add_field('desc', record[:description])
def analyzer
@analyzer ||=
# We can now instantiate the engine
engine =
# and create an index of some data
records = [
{:name => "Moonstone", :description => "A simple JRuby wrapper around Lucene"},
{:name => "Foo", :description => "A search engine based on Moonstone"}
# By convention the index method accepts an Enumerable that yields hashes

#Search for data
q ="name", "Moonstone")
documents =
documents.each {|d| puts d['name']}
That's it in a nutshell. There are some more examples in the README on github, and more documentation is coming soon.

Happy searching!