Q20: How do Text Indexes and Geospatial Indexes operate?

  • Text Index: Supports searching string content for keywords, stemming, and relevance scoring ($text: { $search: 'database' }).
  • 2dsphere Index: Supports queries on a two-dimensional sphere (Earth geometry) using GeoJSON objects (Point, Polygon) for proximity queries like $near and $geoWithin.
Key Takeaways
  • Text indexes enable full-text search and keyword relevance ranking.

  • 2dsphere indexes calculate physical spherical distances using GeoJSON.

Knowledge Check

Which GeoJSON type is used to represent location coordinates [longitude, latitude] for 2dsphere queries?