Coder Social home page Coder Social logo

elasticsearch-rake-tasks's Introduction

Elasticsearch::Rake::Tasks

a collection of useful tasks to support a lean elasticsearch development workflow

Installation

Add this line to your application's Gemfile:

gem 'elasticsearch-rake-tasks'

And then execute:

$ bundle

Or install it yourself as:

$ gem install elasticsearch-rake-tasks

Usage

In your Rakefile, use:

load 'elasticsearch-rake-tasks.rake'

Usage

In order to get the elasticsearch rake tasks to find all templates and settings for an index, the following folder structure must be in place.

./resources
|-- elasticsearch
  |-- templates
    |-- my_index <--- your index name
      |-- mappings
        |-- _default.yaml   <--- shared definitions
        |-- type_a.yaml     <--- a type
        |-- ..              <--- other types
      |-- settings.yaml     <--- index settings
      |-- template_pattern  <--- if you want to use this as a template,
                                 this file holds your pattern

The elasticsearch folder must be located under a resources folder in the root directory of your project. Inside the templates folder a list of directories define the indices for which mappings and settings are used from, in the example above an index my_index would the available.

This will be configurable in future versions.

The following folders & files are used:

  • settings.yaml defines the analyzers and filters that are made available for use in the type mappings
  • template_pattern is the template pattern, as described elasticsearch index template guide.
  • mappings is the folder where all type definitions reside. The files names must match exactly the document types that are indexed, e.g. when a document is of type Tweet, a Tweet.yaml (case sensitive) must be available in this folder describing the properties of such a document
  • _default.yaml is typically the base type definition from which all types inherit shared definitions

Usage

To show all available rake tasks, type bundle exec rake -T from root. When the elasticsearch folder structure is in place all settings for specified indices are automatically found and shown.

rake es:my_index:compile

Compiles the template for index my_index, while

rake es:my_index:reset

deletes the given template and recreates it.

rake es:dump[server,index]

Dumps the content of the ES index from given server to a file located under ./resources/elasticsearch/dumps. To fill an elasticsearch index with data from a seed file use

rake es:seed[server,index]

this will seed the content of the file into the index. The last rake task is used to dump the content from index into another.

rake es:reindex[server,index,index_to]

and should be used whenever the mappings or settings changed.

Note if no arguments are provided to the rake tasks es:dump, es:seed or es:reindex then the environment variables ES_SERVER and ES_INDEX need to be set.

Contributing

  1. Fork it
  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 new Pull Request

elasticsearch-rake-tasks's People

Contributors

justahero avatar schultyy avatar skade avatar xylakant avatar

Watchers

 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.