Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsuwatch/nazrin
a Ruby wrapper of Amazon CloudSearch (aws-sdk), with ActiveRecord, Mongoid support for easy integration with your Rails application.
https://github.com/tsuwatch/nazrin
aws-sdk cloudsearch rails ruby
Last synced: 2 months ago
JSON representation
a Ruby wrapper of Amazon CloudSearch (aws-sdk), with ActiveRecord, Mongoid support for easy integration with your Rails application.
- Host: GitHub
- URL: https://github.com/tsuwatch/nazrin
- Owner: tsuwatch
- License: mit
- Created: 2015-11-11T17:14:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-11-06T01:22:52.000Z (about 4 years ago)
- Last Synced: 2024-10-14T20:08:33.296Z (3 months ago)
- Topics: aws-sdk, cloudsearch, rails, ruby
- Language: Ruby
- Homepage:
- Size: 96.7 KB
- Stars: 48
- Watchers: 4
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Nazrin
[![Gem Version](https://badge.fury.io/rb/nazrin.svg)](https://badge.fury.io/rb/nazrin)
[![Build Status](https://travis-ci.org/tsuwatch/nazrin.svg?branch=master)](https://travis-ci.org/tsuwatch/nazrin)
[![Coverage Status](https://coveralls.io/repos/tsuwatch/nazrin/badge.svg?branch=readme&service=github)](https://coveralls.io/github/tsuwatch/nazrin?branch=readme)
[![Code Climate](https://codeclimate.com/github/tsuwatch/nazrin/badges/gpa.svg)](https://codeclimate.com/github/tsuwatch/nazrin)Nazrin is a Ruby wrapper for Amazon CloudSearch (aws-sdk), with ActiveRecord, Mongoid support for easy integration with your Rails application.
>*Nazrin has the ability of the extent which find what you're looking for...*
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'nazrin'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install nazrin
## Usage
### in Ruby on Rails
```ruby
$ bundle exec rails g nazrin:config # execute before including nazrin to modelNazrin.configure do |config|
config.debug_mode = false
config.mode = 'production'
config.search_endpoint = ''
config.document_endpoint = ''
config.region = ''
config.access_key_id = ''
config.secret_access_key = ''
config.logger = nil
end
``````ruby
class Post < ActiveRecord::Base
include Nazrin::Searchable# You can override settings
searchable_configure do |config|
config.search_endpoint = 'http://example.com/override-search-endpoint'
config.document_endpoint = 'http://example.com/override-document-endpoint'# If you set domain_name, CloudSearch data using index_fields configured for the search domain is loaded, not a database.
# So you can use nazrin for plain object
config.domain_name = 'my-cloudsearch-domain-name'
endsearchable do
fields [:content]
field(:created_at) { created_at.utc.iso8601 }
endafter_create :add_to_index
after_update :update_in_index
after_destroy :delete_from_index
end
```### `.search`
```ruby
result = Post.search(where: :foo, includes: :bar).size(1).start(0).query("(and 'content')").query_parser('structured').execute
=> [#]
# You can access facets
result.facets
=> {}
```### `.batch_operation`
```ruby
post1 = Post.create
post2 = Post.create
post3 = Post.create
post3.destroyPost.batch_operation(
add: [post1, post2],
delete: [post3]
)
```### Supported pagination libraries
If you want to use other supported pagination libraries, for example, `nazrin-kaminari` generates `Kaminari::PaginatableArray` instead of `Nazrin::PaginatedArray`.```ruby
gem 'nazrin'
gem 'nazrin-kaminari'
```Currently supported libraries
- kaminari: [nazrin-kaminari](https://github.com/tsuwatch/nazrin-kaminari)
### Sandbox mode
When there is no instance for development and you don't want to request to CloudSearch
```ruby
Nazrin.config.mode = 'sandbox'
```"sandbox" mode where it does nothing with any requests and just returns an empty collection for any searches.
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
1. Fork it ( https://github.com/[my-github-username]/nazrin/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request