From 762d85c95690f510bec4dd8c37c05454ae1be4fc Mon Sep 17 00:00:00 2001 From: Geo Halkiadakis Date: Thu, 11 Apr 2024 19:16:31 +0300 Subject: introduce resemblance; compare match implementations; retro-search in progress --- paths.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'paths.js') diff --git a/paths.js b/paths.js index 6c2d1ac..a2af434 100644 --- a/paths.js +++ b/paths.js @@ -1,8 +1,10 @@ const Router = require('koa-router'); + const kb = require('./pieces/kb-util.js'); const data = require('./pieces/prepare-streams'); const products = require('./data/products.json'); const bench = require('./benchmark/find.js'); +const macthStr = require('./benchmark/match-str.js'); // Prefix all routes with: /items const router = new Router({ @@ -48,16 +50,29 @@ const router = new Router({ // Routes + +router.get('/', (ctx, next) => { + ctx.body = { + success: true, + title: 'oseine', + description: 'oseine search engine is not elastic', + message: 'where are you now?' + } + next(); +}) + router.get('/search', (ctx, next) => { ctx.body = []; next(); }); router.get('/search/:title', (ctx, next) => { + // console.log(ctx); let words = kb.keyboardize(kb.clean(ctx.params.title)).split(' '); ctx.body = { params: ctx.params, - results: words + results: words, + nxt: next }; next(); }); @@ -105,7 +120,14 @@ router.get('/test/json', (ctx, next) => { // easy test route router.get('/bench/fe', (ctx, next) => { // easy test route // test anything ... // ctx.body = bench.compare(); - ctx.body = bench.byFor(); + ctx.body = bench.compare(); + next(); +}); + +router.get('/bench/match', (ctx, next) => { // easy test route + // test anything ... + // ctx.body = bench.compare(); + ctx.body = macthStr.run(); next(); }); -- cgit v1.2.3