diff --git a/api/src/queries/events.ts b/api/src/queries/events.ts index 704f5045..cbbea788 100644 --- a/api/src/queries/events.ts +++ b/api/src/queries/events.ts @@ -5,7 +5,16 @@ import { TermsFilter } from './common'; export const eventsQuery = (queryString: string): QueryDslQueryContainer => ({ multi_match: { query: queryString, - fields: ['id', 'query.title.*^100', 'query.caption.*^10'], + fields: [ + 'id', + 'query.title.*^100', + 'query.caption.*^10', + 'query.series.*^80', + 'query.series.contributors*^8', + 'query.series.contributors.keyword^80', + 'query.format.*^80', + 'query.audiences.*^80', + ], operator: 'or', type: 'cross_fields', minimum_should_match: '-25%', diff --git a/pipeline/src/indices/events.ts b/pipeline/src/indices/events.ts index 5acaef78..1dd9e3cf 100644 --- a/pipeline/src/indices/events.ts +++ b/pipeline/src/indices/events.ts @@ -90,6 +90,40 @@ export const mappings = { }, }, }, + audiences: { + type: 'text', + fields: { + shingles: { + type: 'text', + analyzer: 'english_shingle_analyzer', + }, + cased: { + type: 'text', + analyzer: 'english_cased_analyzer', + }, + keyword: { + type: 'keyword', + normalizer: 'keyword_lowercase', + }, + }, + }, + format: { + type: 'text', + fields: { + shingles: { + type: 'text', + analyzer: 'english_shingle_analyzer', + }, + cased: { + type: 'text', + analyzer: 'english_cased_analyzer', + }, + keyword: { + type: 'keyword', + normalizer: 'keyword_lowercase', + }, + }, + }, 'times.startDateTime': { type: 'date', format: 'date_optional_time', diff --git a/pipeline/src/transformers/eventDocument.ts b/pipeline/src/transformers/eventDocument.ts index c8efe9e6..51397e83 100644 --- a/pipeline/src/transformers/eventDocument.ts +++ b/pipeline/src/transformers/eventDocument.ts @@ -153,6 +153,8 @@ export const transformEventDocument = ( ? { type: 'PrismicImage' as const, ...primaryImage.image } : undefined; + const series = transformSeries(document); + const format = transformFormat(document); const locations = transformLocations(document); @@ -181,14 +183,18 @@ export const transformEventDocument = ( locations, interpretations, audiences, - series: transformSeries(document), + series, isAvailableOnline, }, query: { linkedIdentifiers: linkedDocumentIdentifiers(document), title: asTitle(title), caption: primaryImage?.caption && asText(primaryImage.caption), - series: transformSeries(document), + series, + format: format.label, + audiences: audiences + .map(audience => audience.label) + .filter(isNotUndefined), times: { startDateTime: documentTimes .map(time => time.startDateTime) diff --git a/pipeline/src/types/transformed/index.ts b/pipeline/src/types/transformed/index.ts index 33d30e33..cfc7b3e2 100644 --- a/pipeline/src/types/transformed/index.ts +++ b/pipeline/src/types/transformed/index.ts @@ -80,6 +80,8 @@ export type ElasticsearchEventDocument = { title: string; caption?: string; series: Series; + format?: string; + audiences?: string[]; times: { startDateTime: Date[] }; }; filter: {