Created
November 30, 2016 17:13
-
-
Save alemures/caafcf1113c9107b1d2b32ecc49509e2 to your computer and use it in GitHub Desktop.
Elasticsearch response as string with Node.js client library
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
// Working with elasticsearch client 12.1.0 | |
var elasticsearch = require('elasticsearch'); | |
var client = new elasticsearch.Client({ | |
host: '127.0.0.1:9200', | |
log: 'warning' | |
}); | |
// Override per default deserialize method without JSON.parse() | |
client.transport.serializer.deserialize = function (str) { | |
if (typeof str === 'string') { | |
return str; | |
} | |
}; | |
client.search( | |
{ | |
index: 'index', | |
type: 'type', | |
body: { | |
query: { | |
match_all: {} | |
} | |
} | |
}, function (err, response) { | |
console.log(err || response); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment