From 084a1fb58b70a3e643d0c0265bb1ca7ffd71e3e9 Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Wed, 24 Jul 2024 12:54:03 -0500 Subject: [PATCH] Circulars: enable basic lucene search this commit adds the most basic form of lucene search, which can be enabled by adding the CIRCULARS_LUCENE feature flag. Additional tuning of field weighting and some type of workaround for the autor search will be required to make it more functional, as well as documentation instructing users on making use of lucene search. --- app/routes/circulars/circulars.server.ts | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/routes/circulars/circulars.server.ts b/app/routes/circulars/circulars.server.ts index 9c65084a3..c839e8d73 100644 --- a/app/routes/circulars/circulars.server.ts +++ b/app/routes/circulars/circulars.server.ts @@ -32,7 +32,7 @@ import type { CircularMetadata, } from './circulars.lib' import { sendEmail } from '~/lib/email.server' -import { origin } from '~/lib/env.server' +import { feature, origin } from '~/lib/env.server' // A type with certain keys required. type Require = Omit & Required> @@ -158,6 +158,22 @@ export async function search({ }, } + const queryObj = query + ? feature('CICRULARS_LUCENE') + ? { + simple_query_string: { + query, + fields: ['submitter', 'subject', 'body'], + }, + } + : { + multi_match: { + query, + fields: ['submitter', 'subject', 'body'], + }, + } + : undefined + const { body: { hits: { @@ -170,14 +186,7 @@ export async function search({ body: { query: { bool: { - must: query - ? { - multi_match: { - query, - fields: ['submitter', 'subject', 'body'], - }, - } - : undefined, + must: queryObj, filter: { range: { createdOn: {