toptal / chewy_example Goto Github PK
View Code? Open in Web Editor NEWChewy example application
Chewy example application
Please host your example on heroku it is difficult to build
Thanks for this example, It's been very helpful. I see you included elasticsearch-extensions, theoretically allowing highlighting of hits (I hope). Or is that only for CLI stuff?
We've defined the following field (hard-coded purely for this example)
field :meta_attributes, type: 'object', value: -> { { color: :blue } }
And now all of our tests are giving us backtraces:
Failure/Error: product = create(:product, :with_meta)
Chewy::ImportFailed:
Import failed for `ProductsIndex::Product` with:
Index errors:
`{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse [meta_attributes]", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"unknown property [color]"}}`
on 1 documents: ["1"]
# ...gems/chewy-0.8.3/lib/chewy/type/import.rb:59:in `import!'
# ...gems/chewy-0.8.3/lib/chewy/strategy/urgent.rb:13:in `update'
# ...gems/chewy-0.8.3/lib/chewy/type/observe.rb:70:in `update_index'
# ...gems/chewy-0.8.3/lib/chewy/type/observe.rb:28:in `block in update_proc'
the meta_attibutes
field is dynamic, it can change depending on the product, but parking that for a second surely the above should work when it's hard coded?
Is this possibly some configuration issue we're not setting?
Hi there. I can't seem to get this started. I have an es installation, so I changed host in chewy.yml from 9250 to 9200 but that didn't fix the problem.
I've tried just rake db:setup and the following command that your readme says to use, and I get the same thing every time.
Chewy::UndefinedUpdateStrategy: Index update strategy is undefined in current context. Please wrap your code with Chewy.strategy(:strategy_name) block.
help!
$ RAILS_ENV=test rake db:setup && rake spec
-- create_table("books", {:force=>true})
-> 0.0331s
-- create_table("dudes", {:force=>true})
-> 0.0013s
-- create_table("taggings", {:force=>true})
-> 0.0016s
-- add_index("taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], {:name=>"taggings_idx", :unique=>true})
-> 0.0010s
-- create_table("tags", {:force=>true})
-> 0.0010s
-- add_index("tags", ["name"], {:name=>"index_tags_on_name", :unique=>true})
-> 0.0008s
-- create_table("videos", {:force=>true})
-> 0.0011s
-- initialize_schema_migrations_table()
-> 0.0028s
rake aborted!
Chewy::UndefinedUpdateStrategy: Index update strategy is undefined in current context.
Please wrap your code with Chewy.strategy(:strategy_name) block.
/Users/darby/.rvm/gems/ruby-2.0.0-p0/bundler/gems/chewy-7f38c5a094c6/lib/chewy/strategy/base.rb:17:in update' /Users/darby/.rvm/gems/ruby-2.0.0-p0/bundler/gems/chewy-7f38c5a094c6/lib/chewy/type/observe.rb:54:in
update_index'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/bundler/gems/chewy-7f38c5a094c6/lib/chewy/type/observe.rb:44:in block in update_index' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:394:in
_run__3044157516336772284__save__callbacks'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in run_callbacks' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in
create_or_update'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:128:in save!' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/validations.rb:57:in
save!'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/dirty.rb:41:in save!' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in
block in save!'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:326:in block in with_transaction_returning_status' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
block in transaction'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in within_new_transaction' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
transaction'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in transaction' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:323:in
with_transaction_returning_status'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in save!' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/configuration.rb:14:in
block in initialize'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:15:in []' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:15:in
create'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:12:in block in result' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in
tap'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in result' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/factory.rb:42:in
run'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:23:in block in run' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:161:in
instrument'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:22:in run' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:5:in
association'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/evaluator.rb:31:in association' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/attribute/association.rb:19:in
block in to_proc'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/evaluator.rb:71:in instance_exec' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/evaluator.rb:71:in
block in define_attribute'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:56:in get' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:16:in
block (2 levels) in object'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:15:in each' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:15:in
block in object'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:14:in tap' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:14:in
object'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:12:in object' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in
result'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/factory.rb:42:in run' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:23:in
block in run'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:161:in instrument' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:22:in
run'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in block in define_singular_strategy_method' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:28:in
block (2 levels) in define_list_strategy_method'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:28:in times' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:28:in
each'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:28:in map' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:28:in
block in define_list_strategy_method'
/Users/darby/_darby/RubymineProjects/chewy_example/db/seeds.rb:9:in <top (required)>' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in
load'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in block in load' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in
load_dependency'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in load' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/railties-4.0.2/lib/rails/engine.rb:540:in
load_seed'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:154:in load_seed' /Users/darby/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:181:in
block (2 levels) in <top (required)>'
/Users/darby/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in eval' /Users/darby/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in
Is it wrong that declear the tags type as "String" in entertainment_string.rb line 10? Should be "Array"?
"undefined method reject of String"
attribute :tags, mode: :arrayed, type: String, normalize: ->(value) { value.reject(&:blank?) }
=>
attribute :tags, mode: :arrayed, type: Array, normalize: ->(value) { value.reject(&:blank?) }
I am on elasticsearch 1.7.2 and rails 4.2.1
Thanks for great example
Hello, I am trying to implement this in my local host. When I am trying to run the seed I am getting this Error. I dont understand whats the problem.
Elasticsearch::Transport::Transport::Errors::GatewayTimeout: [504]
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/elasticsearch-transport-1.0.7/lib/elasticsearch/transport/transport/base.rb:132:in __raise_transport_error' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/elasticsearch-transport-1.0.7/lib/elasticsearch/transport/transport/base.rb:224:in
perform_request'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/elasticsearch-transport-1.0.7/lib/elasticsearch/transport/transport/http/faraday.rb:20:in perform_request' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/elasticsearch-transport-1.0.7/lib/elasticsearch/transport/client.rb:115:in
perform_request'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/elasticsearch-api-1.0.7/lib/elasticsearch/api/namespace/common.rb:21:in perform_request' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/elasticsearch-api-1.0.7/lib/elasticsearch/api/actions/indices/exists.rb:45:in
exists'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/index/actions.rb:15:in exists?' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/type/import.rb:24:in
import'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/strategy/atomic.rb:27:in block in leave' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/strategy/atomic.rb:27:in
each'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/strategy/atomic.rb:27:in all?' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/strategy/atomic.rb:27:in
leave'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/strategy.rb:36:in tap' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/strategy.rb:36:in
pop'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy/strategy.rb:44:in wrap' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/chewy-0.7.0/lib/chewy.rb:161:in
strategy'
/home/saiteja/chewy_example/db/seeds.rb:9:in <top (required)>' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in
load'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in block in load' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in
load_dependency'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in load' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/railties-4.2.1/lib/rails/engine.rb:547:in
load_seed'
/home/saiteja/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:250:in load_seed' /home/saiteja/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:180:in
block (2 levels) in <top (required)>'
Tasks: TOP => db:seed
I haven't any experience with ElastichSearch.
I have installed ElasticSearch 1.0.0-rc1 by this gist https://gist.github.com/wingdspur/2026107
After install I have this error. ElasticSearch is running.
~/projects/chewy_example(master): RAILS_ENV=test rake elasticsearch:start db:setup
Starting 2 Elasticsearch nodes..sh: 1: elasticsearch: not found
sh: 1: elasticsearch: not found
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.