Skip to content

Commit

Permalink
Add audiences and format to transformer for query field. Add to mappi…
Browse files Browse the repository at this point in the history
…ng and relevancy factors
  • Loading branch information
rcantin-w committed Jan 14, 2025
1 parent e53fce4 commit e038202
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
11 changes: 10 additions & 1 deletion api/src/queries/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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%',
Expand Down
34 changes: 34 additions & 0 deletions pipeline/src/indices/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 8 additions & 2 deletions pipeline/src/transformers/eventDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pipeline/src/types/transformed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export type ElasticsearchEventDocument = {
title: string;
caption?: string;
series: Series;
format?: string;
audiences?: string[];
times: { startDateTime: Date[] };
};
filter: {
Expand Down

0 comments on commit e038202

Please sign in to comment.