Search code examples
mongodb-atlas-search

Failing to Write Any Query using MongoDB Atlas Search Index


I get this error when I try to run any aggregation using $search in a MongoDB Atlas Search index.

Remote error from mongot :: caused by :: Error connecting to localhost:28000 (127.0.0.1:28000) :: caused by :: Connection refused

Solution

  • I found that if I created my search index and gave it a name that is not default I need to ensure that I include the index name in the query.

      {
          "$search": {
             "index": "parks_and_recreation", 
             "equals": {
                "path": "open",
                "value": true
             }
          }
        }