1

my team migrate data to mongodb atlas.

I have a question.

How can i combine $searchbeta and geo search in mongodb atlas.

Doug
  • 14,387
  • 17
  • 74
  • 104
David Dev
  • 53
  • 4
  • not sure MongoDB Atlas is different for on prem MongoDB! Can you explain what you are trying to do? – Book Of Zeus Nov 28 '19 at 06:05
  • @BookOfZeus I want to search for stores within 1 km of the user, and can search for store names, sorted by store name or distance. – David Dev Nov 28 '19 at 06:15
  • You should be able to perform the same operations as long you have access and the same data. I recently migrated to MongoDB Atlas and we didn't have any issues running the same actions/queries. If you currently running these queries, try a development instance (it's free i think) import your data and try, you will see right away – Book Of Zeus Nov 28 '19 at 06:34
  • @BookOfZeus My sql like this: db.getCollection('campfire').aggregate([{"$searchBeta":{"search":{"query":["msg"],"path":["title"],"phrase":{"prefix":true}}}},{"$match":{"title":"msg01"}},{"$skip":0},{"$limit":10}]), but query timeout. You can get result like this? – David Dev Nov 28 '19 at 06:53
  • @BookOfZeus By the way, i insert 1.5 million test data. This problem was not found when the amount of data was small. – David Dev Nov 28 '19 at 06:56
  • Query time out means you probably does not use proper index, make sure your indexes looks good. Run an explain() on it to see whats going on: `db.campfire.explain()` – Book Of Zeus Nov 29 '19 at 17:35

1 Answers1

1

The $search (or $searchBeta) stage now supports geospatial queries. Your field that contains geospatial data must be mapped to geo type. Then there are a few possible ways to query that data: near, geoWithin and geoShape.

Oren
  • 589
  • 4
  • 10