RippleSearchable
Mongoid / Active Record style query criteria DSL and Scoping for Ripple using RIAK's solr search interface. (riak_search must be enabled)
RippleSearchable adds named scopes, and chainable Criteria methods such as :where, :lt, :lte, :gt, :gte, :between along with :sort, :skip, :limit options to your Ripple::Document models.
Installation
Add this line to your application's Gemfile:
gem 'ripple_searchable'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ripple_searchable
Usage
Criteria:
Any of the following criteria can be chained:
:where, :lt, :lte, :gt, :gte, :between, with sort, :skip, :limit
=== Example:
Product.where(tags: "nerd", name: "joe", something: 2).
or({can_sell:1}, {can_sell: 3}).
between(availibility: 1..3, price: [3, 12]).
gte(quantity: 0, ratings: 5).
sort(:created_at, :desc).limit(5)
Scoping
Mongoid / Active Record style named scopes:
Use 'scope' class method to create a named scope that can be accessed from the class level or chained to criteria by the provided name.
=== Example:
class Product
include Ripple::Document
scope :active, where(active: true)
scope :avail, ->(count){ where(quantity: count)}
end
See docs for method details.
TODO:
Ability to bypass default scopes when using named scopes Write better docs.
Contributing
This gem is still under heavy development. Feel free to contribute.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request