Skip to content

Instantly share code, notes, and snippets.

@phillro
Created August 5, 2011 02:26
Show Gist options
  • Select an option

  • Save phillro/1126806 to your computer and use it in GitHub Desktop.

Select an option

Save phillro/1126806 to your computer and use it in GitHub Desktop.
var serverOptions = {
host: 'www.elasticsearchhq.com',
port: 9200,
secure: true,
auth: {
username:'[USERNAME]',
password:'[PASSWORD]'
}
};
var elasticSearchClient = new ElasticSearchClient(serverOptions);
var qryObj = {
field : term
}
elasticSearchClient.search('my_index_name', 'my_type_name', qryObj)
.on('data', function(data) {
console.log(JSON.parse(data))
})
.on('done', function(){
//always returns 0 right now
})
.on('error', function(error){
console.log(error)
})
.exec()
elasticSearchClient.index('my_index_name', 'my_type_name', {'name':'name', id:"1111"})
.on('data', function(data) {
console.log(data)
})
.exec()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment