Skip to content

Instantly share code, notes, and snippets.

@Ananto30
Created November 4, 2020 05:14
Show Gist options
  • Save Ananto30/e701c10b45ab8b54d588cb8bd1a2ea34 to your computer and use it in GitHub Desktop.
Save Ananto30/e701c10b45ab8b54d588cb8bd1a2ea34 to your computer and use it in GitHub Desktop.
db[collection].aggregate(
[
{
"$search": {
"text": {
"query": term,
"path": ["body_en", "chapter_en"],
"fuzzy": {"maxEdits": 1, "maxExpansions": 10},
},
"highlight": {"path": ["body_en", "chapter_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