Search code examples
mongodbmongodb-atlas-search

MongoDB 3.6 autocomplete failed "Command failed with error 40324"


I used the basic autocomplete example provided by MongoDB. Unfortunately, it's causing an exception on the server-side

    db.movies.aggregate([
  {
    $search: {
      "autocomplete": {
        "path": "title",
        "query": "off"
      }
    }
  },
  {
    $limit: 10
  },
  {
    $project: {
      "_id": 0,
      "title": 1
    }
  }
])

Ref: https://docs.atlas.mongodb.com/reference/atlas-search/autocomplete/

org.graalvm.polyglot.PolyglotException: Command failed with error 40324 (Location40324): 'Unrecognized pipeline stage name: '$search'' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "Unrecognized pipeline stage name: '$search'", "code": 40324, "codeName": "Location40324"}

any ideas, how to solve this?


Solution

  • Atlas Search is an Atlas feature. It is not provided by MongoDB binaries you can download.

    You can use https://docs.mongodb.com/manual/text-search/ in both environments (though it is not as powerful) or use Atlas for development & staging.