[JAVA-3767] aggregate functions, not do match correctly Created: 17/Jun/20  Updated: 29/Jun/20  Resolved: 29/Jun/20

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: rodrigo brito Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File logs.txt    

 Description   

with this code bellow: 

mongoTemplate.getCollection(COLLECTION_NAME).aggregate(
Arrays.asList(

Aggregates.match(Filters.eq("cpfCnpj",cpfCnpj))
,
Aggregates.group(
new Document()
.append("cpfCnpj", "$cpfCnpj")
.append("namPostalArea", "$namPostalArea")
.append("namDistrict", "$namDistrict")
.append("namFederationUnit", "$namFederationUnit")
.append("namCity", "$namCity")
.append("quantity", "$quantity")
)
,
Aggregates.group(
new Document().append("cpfCnpj", "$_id.cpfCnpj")
,Accumulators.sum("totalDistinctAddresses", "$_id.quantity")
)
,
Aggregates.project(
Projections.fields(
Projections.excludeId(),
Projections.computed("cpfCnpj", "$_id.cpfCnpj"),
Projections.include("totalDistinctAddresses")
)
)
,
Aggregates.merge(VIEW_NAME, new MergeOptions()
.uniqueIdentifier("cpfCnpj")
.whenNotMatched(MergeOptions.WhenNotMatched.INSERT)
.whenMatchedPipeline(
Arrays.asList(new Document()
.append("$addFields", new Document()
.append("totalDistinctAddresses", new Document("$add", Arrays.asList("$totalDistinctAddresses", "$$new.totalDistinctAddresses")))
)
)
)
)
)
)

 

if has only one cpfCnpj in the collection,  it is doing aggregation for 113 items of the collection, the final result is correctly, but with match stage and contain only one of the cpf used, should do only one aggregation.

 

The driver version is 4.0.3

 

the data used in the log are fake , so not contain sensitive data

 

I attached the log event, the first log event is the query used in match stage.

 

 



 Comments   
Comment by Esha Bhargava [ 29/Jun/20 ]

Hi there, thank you for reaching out. As this sounds like a support issue, I wanted to give you some resources to get this questioned answered more quickly:

  • our MongoDB support portal, located at support.mongodb.com
  • our MongoDB community portal, located here
    -If you are an Atlas customer, there is free support offered 24/7 in the lower right hand corner of the UI.
    Just in case you have already opened a support case and are not receiving sufficient help, please let me know and I can facilitate escalating your issue.
    Thank you!
Generated at Thu Feb 08 09:00:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.