While getting data from the Aggregation query in the Reactor approach using Spring Data I have observed that even if I’m getting a few hundred of results, the Mongo Atlas shows only 32 returned documents always.
Hi @Bartosz_Skorka and welcome to the MongoDB Community Forum
The alert message as mentioned:
I have observed that one of my queries caused a lot of Mongo Atlas alerts related to Examined / Returned ratio - “Query Targeting: Scanned Objects / Returned has gone above 1000”.
is explained in the Query Targeting Documentation, which says, the query is scanning more documents than the number of documents getting retuned from the query.
This alert, however, may be resolved by using proper indexing in the collection. The Indexing Strategies documentation will be a good resource to start with.
Further, it would be helpful if you could share some details regarding the error being seen:
A sample document with the query you are trying to use.
Does the same query returns correct number of documents are returned without the Spring Data MongoDB Reactive library?
Can you also confirm if the issue of returning lesser number of document in Atlas is only seen through the application, or it happens when you querying through Atlas/Compass/Shell too.
In addition, if you are an Atlas customer, would recommend you to contact Atlas Customer support for detailed assessment.