0

I'm trying to use $text search inside $or.

await Creators.aggregate([
 {$match: {
  $or: [
    { $creatorId: { $in: [407, 409] } }, 
    { $text: { $search: "Michael"} } ] 
  } }
])

The query won't work. But the $text without $or works fine.

Does anyone have an idea about this? Thank you.

Puneet Singh
  • 3,477
  • 1
  • 26
  • 39
noyruto88
  • 767
  • 2
  • 18
  • 40
  • Does this answer your question? [MongoDB: $or a full-text search and an $in](https://stackoverflow.com/questions/26116182/mongodb-or-a-full-text-search-and-an-in) – Puneet Singh May 18 '20 at 08:35

1 Answers1

1

The $text operator expression cannot used in $or or $not expressions when used in aggregation. Refer to doc

nayakam
  • 4,149
  • 7
  • 42
  • 62