Geo CentreSphere Query

Given I have a Search Index with a Geo Mapping, is it possible to use the search index to perform a GeoWithin with a CentreSphere query? I have a lat/lng and radius.

I’ve seen I can do this on the main collection:

db.places.find( {
  loc: { $geoWithin: { $centerSphere: [ [ -88, 30 ], 10/3963.2 ] } }
} )

But is this possible to query using the Search Index?

var point = new GeoJsonPoint<GeoJson2DCoordinates>(); (X, Y Coords)
var results = await collection.Aggregate()
            .Search(Builders<MyDocument>.Search
                    .Compound()
                    .Filter(Builders<MyDocument>.Search.Equals(d => d.IsDeleted, false))
                    .Must(Builders<MyDocument>.Search.GeoWithin(
                        d => d.GeoCode, point)),
                indexName: MyCollectionName)
            .ToListAsync(cancellationToken)

Cheers

Added a 2dSpehere index to the collection, and used the $near operator on the collection with this index over the Search index

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