Skip to content

Commit

Permalink
Merge pull request #1 from tylerbarna/publicBranch
Browse files Browse the repository at this point in the history
add NLP feature flag
  • Loading branch information
ronitagarwala01 authored Dec 18, 2023
2 parents a12f378 + 049503b commit dcaba60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/routes/_gcn.circulars._archive._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ import DateSelectorButton from './DateSelectorButton'
import DetailsDropdownContent from '~/components/DetailsDropdownContent'
import Hint from '~/components/Hint'
import { useFeature } from '~/root'
import { feature } from '~/lib/env.server'

import searchImg from 'nasawds/src/img/usa-icons-bg/search--white.svg'

export async function loader({ request: { url } }: DataFunctionArgs) {
const useNLP = feature('CIRCULARS_USE_NLP')
const { searchParams } = new URL(url)
const query = searchParams.get('query') || undefined
if (query) {
Expand All @@ -58,6 +60,7 @@ export async function loader({ request: { url } }: DataFunctionArgs) {
limit,
startDate,
endDate,
useNLP,
})

return { page, ...results }
Expand Down
7 changes: 4 additions & 3 deletions app/routes/_gcn.circulars/circulars.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ export async function search({
limit,
startDate,
endDate,
useNLP
}: {
query?: string
page?: number
limit?: number
startDate?: string
endDate?: string
useNLP?: boolean
}): Promise<{
items: CircularMetadata[]
totalPages: number
Expand Down Expand Up @@ -130,7 +132,6 @@ export async function search({
console.log('Error: ', e)
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const nlpSearchQuery = query
? {
bool: {
Expand All @@ -157,7 +158,6 @@ export async function search({
}
: { match_all: {} }

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const searchQuery = {
bool: {
must: query
Expand All @@ -179,6 +179,7 @@ export async function search({
},
}

const chosenQuery = useNLP ? nlpSearchQuery : searchQuery
const {
body: {
hits: {
Expand All @@ -189,7 +190,7 @@ export async function search({
} = await client.search({
index: 'circulars',
body: {
query: nlpSearchQuery,
query: chosenQuery,
fields: ['subject'],
_source: false,
sort: {
Expand Down

0 comments on commit dcaba60

Please sign in to comment.