I'm trying to build an Express.js application that queries my elasticsearch running on a different server. I created an express scaffold app, and the only thing I've changed is in routes/index.js. I changed it to look like the following:
var express = require('express');
var router = express.Router();
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
host: 'http://SERVERDNS.com:9200/'
});
/* GET home page. */
router.get('/', function(req, res) {
res.render('index', { title: 'Express' });
});
router.get('/search', function(req, res) {
var wut = client.search({
index:"test-papers-es",
type:"test-papers-es",
body: {query:
{"match": req.query}
}
});
console.log(wut);
res.send(wut);
console.log(wut);
console.log(req.query);
});
module.exports = router;
The problem is, when I send a query like so:
http://SERVERDNS.com:3000/search?title=gene
I don't get a response (I'm expecting JSON). The console.log for my client.search(var wut) code is this:
{ _bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined,
_settledValue: undefined,
_boundTo: undefined,
abort: [Function: abortRequest] }
And my req.query looks like this:{ title: 'gene' }
Any idea of what I did wrong?
{"isFulfilled":false,"isRejected":false}