Skip to content

Commit 868d179

Browse files
committed
Reduce fuzzy maxEdits from 2 to 1 to prevent over-matching
maxEdits=2 was too permissive, causing 'james cameron' to match 'jane campion' (james→jane=2 edits, cameron→campion=2 edits). maxEdits=1 provides typo tolerance for minor mistakes while preventing false positives from similar-but-different names.
1 parent 6cf9190 commit 868d179

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

mflix/server/java-spring/src/main/java/com/mongodb/samplemflix/service/MovieServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public List<Movie> searchMovies(MovieSearchRequest searchRequest) {
661661
.append("path", Movie.Fields.DIRECTORS)
662662
.append("matchCriteria", "all")
663663
.append("fuzzy", new Document()
664-
.append("maxEdits", 2)
664+
.append("maxEdits", 1)
665665
.append("prefixLength", 2)))
666666
))
667667
.append("minimumShouldMatch", 1)
@@ -685,7 +685,7 @@ public List<Movie> searchMovies(MovieSearchRequest searchRequest) {
685685
.append("path", Movie.Fields.WRITERS)
686686
.append("matchCriteria", "all")
687687
.append("fuzzy", new Document()
688-
.append("maxEdits", 2)
688+
.append("maxEdits", 1)
689689
.append("prefixLength", 2)))
690690
))
691691
.append("minimumShouldMatch", 1)
@@ -709,7 +709,7 @@ public List<Movie> searchMovies(MovieSearchRequest searchRequest) {
709709
.append("path", Movie.Fields.CAST)
710710
.append("matchCriteria", "all")
711711
.append("fuzzy", new Document()
712-
.append("maxEdits", 2)
712+
.append("maxEdits", 1)
713713
.append("prefixLength", 2)))
714714
))
715715
.append("minimumShouldMatch", 1)

mflix/server/js-express/src/controllers/movieController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ export async function searchMovies(req: Request, res: Response): Promise<void> {
599599
query: directors,
600600
path: "directors",
601601
matchCriteria: "all",
602-
fuzzy: { maxEdits: 2, prefixLength: 2 },
602+
fuzzy: { maxEdits: 1, prefixLength: 2 },
603603
},
604604
},
605605
],
@@ -620,7 +620,7 @@ export async function searchMovies(req: Request, res: Response): Promise<void> {
620620
query: writers,
621621
path: "writers",
622622
matchCriteria: "all",
623-
fuzzy: { maxEdits: 2, prefixLength: 2 },
623+
fuzzy: { maxEdits: 1, prefixLength: 2 },
624624
},
625625
},
626626
],
@@ -641,7 +641,7 @@ export async function searchMovies(req: Request, res: Response): Promise<void> {
641641
query: cast,
642642
path: "cast",
643643
matchCriteria: "all",
644-
fuzzy: { maxEdits: 2, prefixLength: 2 },
644+
fuzzy: { maxEdits: 1, prefixLength: 2 },
645645
},
646646
},
647647
],

mflix/server/python-fastapi/src/routers/movies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async def search_movies(
170170
{"text": {"query": directors, "path": "directors", "matchCriteria": "all"}},
171171
# Lower score: fuzzy match (typo tolerance)
172172
{"text": {"query": directors, "path": "directors", "matchCriteria": "all",
173-
"fuzzy": {"maxEdits": 2, "prefixLength": 2}}}
173+
"fuzzy": {"maxEdits": 1, "prefixLength": 2}}}
174174
],
175175
"minimumShouldMatch": 1
176176
}
@@ -184,7 +184,7 @@ async def search_movies(
184184
{"phrase": {"query": writers, "path": "writers"}},
185185
{"text": {"query": writers, "path": "writers", "matchCriteria": "all"}},
186186
{"text": {"query": writers, "path": "writers", "matchCriteria": "all",
187-
"fuzzy": {"maxEdits": 2, "prefixLength": 2}}}
187+
"fuzzy": {"maxEdits": 1, "prefixLength": 2}}}
188188
],
189189
"minimumShouldMatch": 1
190190
}
@@ -198,7 +198,7 @@ async def search_movies(
198198
{"phrase": {"query": cast, "path": "cast"}},
199199
{"text": {"query": cast, "path": "cast", "matchCriteria": "all"}},
200200
{"text": {"query": cast, "path": "cast", "matchCriteria": "all",
201-
"fuzzy": {"maxEdits": 2, "prefixLength": 2}}}
201+
"fuzzy": {"maxEdits": 1, "prefixLength": 2}}}
202202
],
203203
"minimumShouldMatch": 1
204204
}

0 commit comments

Comments
 (0)