Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-10259

text search in aggregation limitation says that it cannot be used inside "$or", but it looks like you can.

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • manual, Server
    • None

    Description

      From https://docs.mongodb.com/manual/tutorial/text-search-in-aggregation/#restrictions

      It says "The text operator expression cannot appear in $or or $not expressions."

      However I just tried this and surprisingly, it seems to work:

      > db.articles.aggregate( [ { $match: {"$or":[{ $text: { $search: "cake" } },{"_id":ObjectId("591a0db04b8a0358aec1e104")}] }}  ] )
      { "_id" : ObjectId("591a0db04b8a0358aec1e104"), "x" : "cake" }
      

      On the other hand, using it with $nor does not seem to be allowed (though the docs don't say so)

      Attachments

        Activity

          People

            Unassigned Unassigned
            mikeo@mongodb.com Michael O'Brien
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              1 year, 14 weeks, 2 days ago