The elasticsearch-dsl gem provides a Ruby API for the Elasticsearch Query DSL. The library allows to programmatically build complex search definitions for {es} in Ruby, which are translated to Hashes, and ultimately, JSON, the language of {es}.
See the README for more information.