Skip to content

Commit

Permalink
fix: meilisearch does not support nested searchable fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwitr0 committed Nov 5, 2023
1 parent d5729cc commit bd6c849
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/movie/entities/v1.4/meili-movie.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ItemName, Logo, Movie, Name, Rating, ShortImage, Votes, YearRange } from '../../schemas/movie.schema';
import { MeiliMovieEntity } from '../meili-movie.entity';
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
import { Expose } from 'class-transformer';

export class MeiliMovieEntityV1_4 extends OmitType(MeiliMovieEntity, [
'names',
Expand All @@ -15,62 +16,85 @@ export class MeiliMovieEntityV1_4 extends OmitType(MeiliMovieEntity, [
'fromMongoDocument',
] as const) {
@ApiProperty({ type: () => Name, isArray: true })
@Expose()
names: Name[];

@ApiPropertyOptional({ type: () => Logo })
@Expose()
logo: Logo;

@ApiPropertyOptional({ type: () => ShortImage })
@Expose()
poster: ShortImage;

@ApiPropertyOptional({ type: () => ShortImage })
@Expose()
backdrop: ShortImage;

@ApiPropertyOptional({ type: () => Rating })
@Expose()
rating: Rating;

@ApiPropertyOptional({ type: () => Votes })
@Expose()
votes: Votes;

@ApiPropertyOptional({ type: () => ItemName, isArray: true })
@Expose()
genres: ItemName[];

@ApiPropertyOptional({ type: () => ItemName, isArray: true })
@Expose()
countries: ItemName[];

@ApiPropertyOptional({ type: () => YearRange, isArray: true })
@Expose()
releaseYears: YearRange[];

@ApiProperty()
@Expose()
isSeries: boolean;

@ApiProperty()
@Expose()
ticketsOnSale: boolean;

@ApiProperty()
@Expose()
totalSeriesLength: number;

@ApiProperty()
@Expose()
seriesLength: number;

@ApiProperty()
@Expose()
ratingMpaa: string;

@ApiProperty()
@Expose()
ageRating: number;

@ApiProperty()
@Expose()
top10?: number | null;

@ApiProperty()
@Expose()
top250?: number | null;

@ApiProperty()
@Expose()
typeNumber: number;

@ApiProperty()
@Expose()
status: string;

internalNames: string[];
internalRating: number;
internalVotes: number;

constructor(movie: Partial<MeiliMovieEntityV1_4>) {
super();
Object.assign(this, movie);
Expand Down Expand Up @@ -106,6 +130,10 @@ export class MeiliMovieEntityV1_4 extends OmitType(MeiliMovieEntity, [
this.typeNumber = movie.typeNumber;
this.status = movie.status;

this.internalNames = movie.names ? movie.names.map(({ name }) => name) : [];
this.internalRating = movie.rating.kp || movie.rating.imdb || 0;
this.internalVotes = Number(movie.votes.kp) || Number(movie.votes.imdb) || 0;

return this;
}
}

0 comments on commit bd6c849

Please sign in to comment.