diff options
author | Marvin Borner | 2018-11-08 18:19:13 +0100 |
---|---|---|
committer | Marvin Borner | 2018-11-08 18:19:13 +0100 |
commit | d243f31f7d245efce4bd857b32dc758205c28758 (patch) | |
tree | d615c1d5443aeea0ab7dd99c2bd08b34e6ec66f6 /routes/search.js | |
parent | 641ed66837dd4bd45c977978609fb38cbeac9319 (diff) |
Improved search algorithms
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 |