GithubHelp home page GithubHelp logo

joshvar88 / spree_elasticsearch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from javereec/spree_elasticsearch

0.0 2.0 0.0 164 KB

Integration with Elasticsearch for the Spree framework.

License: BSD 3-Clause "New" or "Revised" License

Ruby 85.69% JavaScript 0.18% CSS 2.04% HTML 12.09%

spree_elasticsearch's Introduction

Spree Elasticsearch

This extension uses elasticsearch-ruby for integration of Elasticsearch with Spree. This is preconfigured for a certain use case, but by all means override where necessary.

To understand what is going on, you should first learn about Elasticsearch. Some great resources:

Installation

Add spree_elasticsearch to your Gemfile:

gem 'spree_elasticsearch', github: 'javereec/spree_elasticsearch', branch: '3-0-stable'

Bundle your dependencies and run the installation generator:

bundle
touch config/elasticsearch.yml # temporary install workaround
bundle exec rails g spree_elasticsearch:install

Edit the file in config/elasticsearch.yml to match your configuration.

Edit the spree initializer in config/initializers/spree.rb and use the elasticsearch searcher.

Spree.config do |config|
  config.searcher_class = Spree::Search::Elasticsearch
end

Create a decorator for Product model to implement callbacks and update the index. This gem doesn't implement a default method as there are several options. For sites with lots of products and changes to these products, the recommended way would be to use a sidekiq task. Check the elasticsearch-rails documentation for different options.

For example using the model callbacks

module Spree
  Product.class_eval do
    include Elasticsearch::Model::Callbacks
  end
end

Elasticsearch

Elasticsearch is very easy to install. Get and unzip elasticsearch 1.x.x: http://www.elasticsearch.org/download

Start:

bin/elasticsearch

Execute following to drop index (all) and have a fresh start:

curl -XDELETE 'http://localhost:9200'

Elasticsearch has a nifty plugin, called Marvel, you can install to view the status of the cluster, but which can also serve as a tool to debug the commands you're running against the cluser. This tool is free for development purposes, but requires a license for production environments. You can install it by executing the following.

bin/plugin -i elasticsearch/marvel/latest

Testing

Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.

bundle
bundle exec rake test_app
bundle exec rspec spec

When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:

require 'spree_elasticsearch/factories'

Please note that these test require an actual instance of Elasticsearch. ] A helper product decorator class is includes to update the index when saving a product.

Copyright (c) 2014-2015 Jan Vereecken, released under the New BSD License

spree_elasticsearch's People

Contributors

alepore avatar geekoncoffee avatar acreilly avatar

Watchers

Joshva avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.