How do I use the 2dsphere index when mongodb queries a collection of rectangular area coordinates?

1. See the introduction of the official website in which the rectangle $box method only supports 2d indexes.
Only the 2d geospatial index supports $box.
the official 2dsphere index is also recommended. The method I know now, geoWithinBox, uses a 2d index instead of the {loc:2dsphere} index I created in the document.

    Filters.geoWithinBox("loc", double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY)

Please tell me how to use the 2dsphere index I created when querying rectangles.

Mar.18,2021
Menu