Skip to content

Instantly share code, notes, and snippets.

@driki
Last active December 10, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save driki/4390503 to your computer and use it in GitHub Desktop.
Save driki/4390503 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'tire'
Tire.configure { logger 'elasticsearch.log', :level => 'debug' }
class Municipality
include Tire::Model::Persistence
include Tire::Model::Search
include Tire::Model::Callbacks
property :id, :type => 'string'
property :name, :type => 'string'
end
class Document
include Tire::Model::Persistence
include Tire::Model::Search
include Tire::Model::Callbacks
property :id, :type => 'string'
property :type, :type => 'string'
end
Tire.index 'municipalities' do
create
muni = Municipality.new(
:id => "ma-newburyport",
:name => "Newburyport")
muni.save
refresh
end
Tire.index 'documents' do
create
doc = Document.new(
:id => "1234",
:type => "Permit")
store(doc, :parent => "ma-newburyport")
refresh
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment