Skip to content

Instantly share code, notes, and snippets.

@Ananto30
Created November 4, 2020 05:21
Show Gist options
  • Save Ananto30/5895300b382152960172060fda731648 to your computer and use it in GitHub Desktop.
Save Ananto30/5895300b382152960172060fda731648 to your computer and use it in GitHub Desktop.
db[collection].aggregate(
[
{
"$search": {
"phrase": {
"query": term,
"path": "body_en",
"slop": 2,
},
"highlight": {"path": "body_en"},
}
},
{"$limit": 50},
{
"$project": {
"_id": 0,
"collection_id": 1,
"collection": 1,
"hadith_no": 1,
"book_no": 1,
"book_en": 1,
"chapter_no": 1,
"chapter_en": 1,
"narrator_en": 1,
"body_en": 1,
"book_ref_no": 1,
"hadith_grade": 1,
"score": {"$meta": "searchScore"},
"highlights": {"$meta": "searchHighlights"},
}
},
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment