Created
December 20, 2016 07:59
-
-
Save mykoweb/9121016f0d7f331b02c8e18e39997fb3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def raw_put(path, body) | |
conn = Faraday.new url: 'http://localhost:9200' | |
conn.put(path) do |req| | |
req.body = body.to_json | |
req.headers['Content-Type'] = 'application/json' | |
end | |
end | |
# Create primary index | |
req_body = { | |
settings: { | |
index: { | |
number_of_shards: 5, # In production, this number would be much larger | |
number_of_replicas: 1 | |
} | |
}, | |
mappings: { | |
patient_type: { | |
properties: { | |
patient_name: { index: 'not_analyzed', type: 'string' }, | |
content: { index: 'not_analyzed', type: 'string' } | |
} | |
} | |
} | |
} | |
raw_put 'patients', req_body | |
client.indices.exists? index: 'patients' # => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment