diff options
Diffstat (limited to 'routes/search.js')
-rw-r--r-- | routes/search.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/routes/search.js b/routes/search.js new file mode 100644 index 0000000..c861f61 --- /dev/null +++ b/routes/search.js @@ -0,0 +1,20 @@ +const database = require("../database"); +const express = require("express"); +const router = express.Router(); + +router.get('/', (req, res, next) => { + database.search("crawled", { + size: 20, + from: 0, + query: { + multi_match: { + query: req.query.q, + fuzziness: 3 // decrease for more specific results + } + } + }).then(results => { + res.json(results.hits) + }) +}); + +module.exports = router;
\ No newline at end of file |