Articles → MONGODB → Exclusion Operator Of Text Search In Mongodb

Exclusion Operator Of Text Search In Mongodb






Purpose





Syntax


db.collection.find({
    $text: {
        $search: "[search query] – [wordToExclude]"
    }
})



Example




Picture showing the sample document collection




db.authors.find({
    $text: {
        $search: "Mongodb -Action2"
    }
})


Picture showing the output of exclusion operator of text search in mongodb



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, May 14, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250