Skip to content

Commit 2491f22

Browse files
authored
Merge pull request #61 from mongodb/docsp-55532-vector-scoring
DOCSP-55532: Add vector scoring to search results
2 parents 30f7fac + 2c97e1c commit 2491f22

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

mflix/client/app/components/MovieCard/MovieCard.module.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@
105105
font-size: 14px;
106106
}
107107

108+
.vectorScore {
109+
margin: 0 0 4px 0;
110+
color: #0066cc;
111+
font-size: 13px;
112+
font-weight: 500;
113+
background: #e6f0ff;
114+
padding: 4px 8px;
115+
border-radius: 4px;
116+
display: inline-block;
117+
}
118+
108119
.movieGenres {
109120
margin: 0;
110121
color: #888;

mflix/client/app/components/MovieCard/MovieCard.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ export default function MovieCard({ movie, isSelected = false, onSelectionChange
6969
{movie.year && (
7070
<p className={movieStyles.movieYear}>({movie.year})</p>
7171
)}
72+
{movie.score !== undefined && (
73+
<p className={movieStyles.vectorScore}>
74+
🎯 Vector Score: {movie.score.toFixed(4)}
75+
</p>
76+
)}
7277
{movie.imdb?.rating && (
7378
<p className={movieStyles.movieRating}>{movie.imdb.rating}/10</p>
7479
)}

mflix/client/app/lib/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ export async function vectorSearchMovies(searchParams: {
725725
genres: item.genres || [],
726726
directors: item.directors || [],
727727
cast: item.cast || [],
728+
score: item.score,
728729
// Add default values for fields not included in VectorSearchResult
729730
fullplot: undefined,
730731
released: undefined,

mflix/client/app/types/movie.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/**
77
* Movie interface for type safety
8-
* Matches the Movie type from the Express backend
8+
* Matches the Movie type from the backend
99
*/
1010
export interface Movie {
1111
_id: string;
@@ -51,11 +51,13 @@ export interface Movie {
5151
};
5252
metacritic?: number;
5353
type?: string;
54+
// Vector search score (only present in vector search results)
55+
score?: number;
5456
}
5557

5658
/**
5759
* API Response interface for the movies endpoint
58-
* Matches the SuccessResponse type from the Express backend
60+
* Matches the SuccessResponse type from the backend
5961
*/
6062
export interface MoviesApiResponse {
6163
success: boolean;

0 commit comments

Comments
 (0)