I have data
[
{
"title": "Football Juventus"
},
{
"title": "Football Milan"
}
]
And index:
db['news'].createIndex({"title": "text"});
I want to select docs where Football
+ (Juventus
| Milan
)
But such query not works:
{
$text: {
$search: '"Football" ("Juventus" | "Milan")'
}
}
Are any ideas?
1
Kindly check if regular expression search works for you.
A sample query may look like
db['news'].find( { title: { $regex: /^(FootballsJuventus)|(FootballsMilan)/ } } )
PS:
- Above query is not tested.
- Indexes work on case sensitive query
- Reference document specified as https://www.mongodb.com/docs/manual/reference/operator/query/regex/