aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/SearchManager.ts
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-05-05 18:26:50 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-05-05 18:26:50 -0400
commit2a9db784a6e3492a8f7d8ce9a745b4f1a0494241 (patch)
treec3a6c50857c3349462e525eec10fb26088292071 /src/server/ApiManagers/SearchManager.ts
parentf706f70451525d4d0716c631cece9d78d76b3bfd (diff)
parent2caf7b7bb80b663b6ba585f88cdbd2d725f8505e (diff)
Merge branch 'master' of https://github.com/brown-dash/Dash-Web into nathan-starter
Diffstat (limited to 'src/server/ApiManagers/SearchManager.ts')
-rw-r--r--src/server/ApiManagers/SearchManager.ts34
1 files changed, 1 insertions, 33 deletions
diff --git a/src/server/ApiManagers/SearchManager.ts b/src/server/ApiManagers/SearchManager.ts
index 72c01def7..92c10975f 100644
--- a/src/server/ApiManagers/SearchManager.ts
+++ b/src/server/ApiManagers/SearchManager.ts
@@ -1,14 +1,11 @@
import { exec } from 'child_process';
import { cyan, green, red, yellow } from 'colors';
-import * as path from 'path';
import { log_execution } from '../ActionUtilities';
-import { Database } from '../database';
import { Method } from '../RouteManager';
import RouteSubscriber from '../RouteSubscriber';
import { Search } from '../Search';
+import { Database } from '../database';
import ApiManager, { Registration } from './ApiManager';
-import { Directory, pathToDirectory } from './UploadManager';
-import { find } from 'find-in-files';
export class SearchManager extends ApiManager {
protected initialize(register: Registration): void {
@@ -35,35 +32,6 @@ export class SearchManager extends ApiManager {
register({
method: Method.GET,
- subscription: '/textsearch',
- secureHandler: async ({ req, res }) => {
- const q = req.query.q;
- if (q === undefined) {
- res.send([]);
- return;
- }
- const resObj: { ids: string[]; numFound: number; lines: string[] } = { ids: [], numFound: 0, lines: [] };
- let results: any;
- const dir = pathToDirectory(Directory.text);
- try {
- const regex = new RegExp(q.toString());
- results = await find({ term: q, flags: 'ig' }, dir, '.txt$');
- for (const result in results) {
- resObj.ids.push(path.basename(result, '.txt').replace(/upload_/, ''));
- resObj.lines.push(results[result].line);
- resObj.numFound++;
- }
- res.send(resObj);
- } catch (e) {
- console.log(red('textsearch:bad RegExp' + q.toString()));
- res.send([]);
- return;
- }
- },
- });
-
- register({
- method: Method.GET,
subscription: '/dashsearch',
secureHandler: async ({ req, res }) => {
const solrQuery: any = {};