summaryrefslogtreecommitdiff
path: root/routes/search.js
blob: c861f6197a569c752fab02ce499088ec7f7d88e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;