Skip to content

Commit

Permalink
[Fix] Improve card name search with phrase matching
Browse files Browse the repository at this point in the history
- Add phrase matching to search compound
- Prioritize phrase matches over repeated keywords

Example:
  Query: "monster reborn"
  Old result: "Monster Reborn Reborn"
  New result: "Monster Reborn"
  • Loading branch information
Satellaa committed Sep 24, 2024
1 parent 652c2c9 commit a0c5098
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/utils/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@ impl QueryHolder {
doc! {
"$search": {
"index": index,
"text": {
"query": query,
"path": path,
"fuzzy": {
"maxEdits": 1
}
"compound": {
"should": [
doc! {
"text": {
"query": query,
"path": path,
"fuzzy": {
"maxEdits": 1
}
}
},
doc! {
"phrase": {
"query": query,
"path": path,
"slop": 0
}
}
]
}
}
}
Expand Down

0 comments on commit a0c5098

Please sign in to comment.