I'm working on an ElasticSearch + React.js project and it's coming along! however, I am running into a problem. I want to make my "/search" query be able to take in the string the my user entered to search. How can I do this? Thank you for the input!const express = require('express'); const bodyParser = require('body-parser'); const morgan = require('morgan'); const PORT = 4000; var client = require ('./connection.js'); var argv = require('yargs').argv; var getJSON = require('get-json'); let app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.get('/', function(req, res){ res.send("Node is running brother"); }); app.get("/search", function (request, response) { client.search({ index: 'club', type: 'clubinfo', body: { query: { match: { "name": "Italian club" } }, } },function (error, data, status) { if (error) { return console.log(error); } else { // Send back the response response.send(data); } }); }); app.listen(PORT, () => console.log('wowzers in me trousers, Listening on port ' + PORT));
Submitted February 12, 2019 at 11:03PM by CharlieCannedFruit
No comments:
Post a Comment