Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-10102: Fixes for nginx elasticsearch proxy. #1007

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/js/job-search.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/js/react/apps/job-search/enum/Global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Global = {
index: 'job_listings',
size: 30,
sortOptions: {
closing: 'closing',
Expand Down
4 changes: 3 additions & 1 deletion src/js/react/apps/job-search/hooks/useIndexQuery.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import useSWR from 'swr';
import { PublicConfiguration } from 'swr/_internal';
import Global from '../enum/Global';

type UseIndexQueryProps = {
// Uses _mquery endpoint if true
Expand All @@ -14,10 +15,11 @@ const useIndexQuery = ({ query, multi, ...rest }: UseIndexQueryProps) => {
const fetcher = () => {
const proxyUrl = drupalSettings?.helfi_react_search?.elastic_proxy_url;
const url: string|undefined = proxyUrl;
const { index } = Global;
const endpoint = multi ? '_msearch' : '_search';
const contentType = `application/${multi ? 'x-ndjson' : 'json'}`;

return fetch(`${url}/${endpoint}`, {
return fetch(`${url}/${index}/${endpoint}`, {
method: 'POST',
headers: {
'Content-Type': contentType,
Expand Down
6 changes: 4 additions & 2 deletions src/js/react/apps/job-search/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getLanguageLabel } from './helpers/Language';
import sortOptions from './helpers/Options';
import { AGGREGATIONS, EMPLOYMENT_FILTER_OPTIONS, LANGUAGE_OPTIONS, PROMOTED_IDS, TASK_AREA_OPTIONS } from './query/queries';
import type OptionType from './types/OptionType';
import Global from './enum/Global';
import type Term from './types/Term';
import type URLParams from './types/URLParams';
import AggregationItem from './types/AggregationItem';
Expand Down Expand Up @@ -105,6 +106,7 @@ type configurations = {

export const configurationsAtom = atom(async(): Promise<configurations> => {
const proxyUrl = drupalSettings?.helfi_react_search?.elastic_proxy_url;
const { index } = Global;
const url: string | undefined = proxyUrl;
const ndjsonHeader = '{}';

Expand All @@ -130,7 +132,7 @@ export const configurationsAtom = atom(async(): Promise<configurations> => {
JSON.stringify(PROMOTED_IDS)
}\n`;

return fetch(`${url}/_msearch`, {
return fetch(`${url}/${index}/_msearch`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-ndjson',
Expand Down Expand Up @@ -307,7 +309,7 @@ export const areaFilterAtom = atom(
{
label: item.label,
value: item.key,
}
}
)
));

Expand Down