Atlas Search with golang driver

I’ve been looking all throughout the mongo-go-driver and haven’t been able to find anything about the atlas search? I’m just a little confused since everything atlas search related has query syntax and I thought might just be using the collection.Find method but there’s nothing in the documentation which talks about being able to query indexes. Any help would be super helpful 🙇🏽‍♂️

You can query Atlas Search indexes using Aggregate with a pipeline like:

mongo.Pipeline{
	bson.D{
		{"$search", bson.D{
			{"text", bson.D{
				{"path", "plot"},
				{"query", "baseball"},
			}},
		}},
	},
}

Check out the Run Atlas Search Queries guide and select Go from the language dropdown to see a full example.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.