diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 966088838b..729df665cd 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -2,6 +2,7 @@ * #1535: Ignore Subscription::q when matching subscriptions for deletion of an entity * #1542: Array Reduction (arrays of one single element are "flattened" to that very element) * #1551: format=simplified for distribute GET /entities gave Normalized for entities from other brokers + * #1557: Cannot count entities if geo query with $near - mongodb doesn't allow it * #1573: pagination not working when entities have the exact same creation date (sort also by entity id) * #1583: If a 'q' contains an ampersand, that ampersand needs to be forwarded as a semicolon * #1593: Modify the type of an entity in a Replace operation (only working in legacy mode) diff --git a/src/lib/orionld/mongoc/mongocEntitiesQuery.cpp b/src/lib/orionld/mongoc/mongocEntitiesQuery.cpp index fa5d65dd86..653ed9954b 100644 --- a/src/lib/orionld/mongoc/mongocEntitiesQuery.cpp +++ b/src/lib/orionld/mongoc/mongocEntitiesQuery.cpp @@ -777,6 +777,18 @@ KjNode* mongocEntitiesQuery { if (geoFilter(&mongoFilter, geoInfoP) == false) return NULL; + + // + // NOTE + // Counting doesn't work with $near|$nearSphere + // Must cancel the count in case it's requested, if it's a geo query with $near + // + if ((geoInfoP->georel == GeorelNear) && (countP != NULL)) + { + LM_W(("Cannot count entities if georel is 'near'. MongoDB doesn't allow it")); + *countP = -2; // Mark the 'absense' of a count + countP = NULL; // This inhibits the count + } } bson_append_document(&options, "projection", 10, &projection);