acreilly / spree_elasticsearch

Integration with Elasticsearch for the Spree framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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'

Bundle your dependencies and run the installation generator:

bundle
bundle exec rails g spree_elasticsearch:install

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

Create a decorator for Product model to implement callbacks and update the index. 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'

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

About

Integration with Elasticsearch for the Spree framework.

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


Languages

Language:Ruby 85.2%Language:HTML 12.5%Language:CSS 2.2%Language:JavaScript 0.2%