Git Product home page Git Product logo

elasticrecord's Introduction

elasticrecord

(Im doing Readme driven development, most of if not all of this is not implemented yet, feel free to help out)

let your model inherit from ElasticRecord::Base, and add any attributes you want

First add it to your Gemfile

gem 'elasticrecord'

then add the following to database.yml

elastic:
  host: localhost
  port: 9200
  index: dailybugle
  mappings:
    article:
    ....
  settings:
    ....

here you should be able to add all the mappings and settings etc for that index.


You then make your model inherit from ElasticRecord::Base

class Article < ElasticRecord::Base

end

Since Elasticsearch is schemaless, there is no point in declaring attributes in the model, you can but you can also add attributes later

NOTE: You still need to know the structure if you plan on making custom mappings or settings, since they can only be set when you create the index, to apply mappings after words you need to delete the index and restart the rails server.

article = Article.new(title:'Who is spiderman?', body:'the spider menace..')
=>
{
   "_index": "dailybugle",
   "_type": "article",
   "_id": "AU71ch-vtiEVeK6SIdAv",
   "_version": 1,
   "created": true
}

elasticrecord's People

Contributors

jb-san avatar

Watchers

 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.