'How to avoid negation while using hyphen?

I have a query that looks similar to:

db.mycollection.find({
     $text: {
        $search: "my -city"
     }
})

If I run this query, it will negate city. But I want to search for the exact phrase my -city. How can I do this?

The text to search could be my-city or my - city or my -city. Is there a way I can instruct mongodb to not use negation as the default behavior and just use the exact string matching?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source