tsuwatch / nazrin Goto Github PK
View Code? Open in Web Editor NEWa Ruby wrapper of Amazon CloudSearch (aws-sdk), with ActiveRecord, Mongoid support for easy integration with your Rails application.
License: MIT License
a Ruby wrapper of Amazon CloudSearch (aws-sdk), with ActiveRecord, Mongoid support for easy integration with your Rails application.
License: MIT License
Is this gem supporting multiple models? I guess the gem supports 1 model at the same time.
Do you have a plan for supporting multiple models?
I'm having a hard time understanding what to pass into .search
and .query
. It would be great to document the options
hash that .search
takes in. If you flesh out some of the documentation, I would be more than willing to contribute some more in the same pattern!
Currently, support one instance.
search
and call execute
causes undefined method error like following. NoMethodError:
undefined method `in' for nil:NilClass
# ./lib/nazrin/data_accessor/mongoid.rb:10:in `block in load_all'
# ./lib/nazrin/data_accessor/mongoid.rb:6:in `each'
# ./lib/nazrin/data_accessor/mongoid.rb:6:in `load_all'
# ./lib/nazrin/data_accessor.rb:64:in `results'
# ./lib/nazrin/search_client.rb:122:in `execute'
# ./spec/nazrin/data_accessor/mongoid_spec.rb:27:in `block (4 levels) in <top (required)>'
The error occurs here .
In this code, right side model
is not the method of DataAccessor
but nil
, because by executing model =
, model
is defined as a new local variable. So we failed to call methods.
Apply this patch and execute rspec.
diff --git a/spec/nazrin/data_accessor/mongoid_spec.rb b/spec/nazrin/data_accessor/mongoid_spec.rb
index 9773fea..fa1b662 100644
--- a/spec/nazrin/data_accessor/mongoid_spec.rb
+++ b/spec/nazrin/data_accessor/mongoid_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Nazrin::DataAccessor::Mongoid do
+describe 'Nazrin::DataAccessor::Mongoid' do
let!(:user) { User.create(email: '[email protected]', created_at: Time.now) }
it { expect(User).to be_respond_to :search }
@@ -22,5 +22,9 @@ describe Nazrin::DataAccessor::Mongoid do
it { expect(User.search.size(1).start(0).execute).to eq [user] }
it { expect(User.search.size(1).start(0).execute.facets).to eq(response.facets) }
end
+
+ context 'with options' do
+ it { expect(User.search({in: {email: ['[email protected]']}}).size(1).start(0).execute).to eq [user] }
+ end
end
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.