From e360ee1557f9f166bdcd2dfd1ad66c26bca7bfa3 Mon Sep 17 00:00:00 2001 From: Nikomiko Date: Thu, 29 Jan 2026 23:46:51 -0500 Subject: [PATCH] fix: word-form search method --- apps/vdb-backend/src/index.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/vdb-backend/src/index.ts b/apps/vdb-backend/src/index.ts index 732530b..6fa3ef6 100644 --- a/apps/vdb-backend/src/index.ts +++ b/apps/vdb-backend/src/index.ts @@ -6,6 +6,9 @@ import fs from 'fs'; ;import { appDataSource } from "./config/dbconfig.js"; import { Lemma, WordForm, Lect } from "./db/dbmodel.js"; import "@total-typescript/ts-reset"; +import { + Like +} from "typeorm"; const RELOAD_SHEET_ON_START = false; const SOURCE_FILE = 'res/sample.tsv' @@ -40,14 +43,13 @@ function initExpress() { return void res.sendStatus(400); } - const lemmas: Lemma[] = ( - await Lemma.find({ relations: { word_forms: { lect: true } } }) - ).filter((e) => { - for (const wf of e.word_forms) { - return wf.word_form.includes(search_term); - } + const word_forms: WordForm[] = await WordForm.find({ + where:{word_form: Like(`%${search_term}%`)}, + relations: { lemma: { word_forms: { lect: true }} } }); + const lemmas = word_forms.map(w=>w.lemma); + res.status(200).send({ terms: lemmas.length, results: lemmas