Last active
December 10, 2015 05:49
-
-
Save driki/4390503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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