[SERVER-33389] aggregate function similar to regex replace Created: 19/Feb/18  Updated: 21/Mar/18  Resolved: 21/Feb/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Sourav Biswas Assignee: Kelsey Schubert
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-32314 Add $replaceOne and $replaceAll expre... Closed
Related
related to SERVER-11947 Add a regex expression to the aggrega... Closed
Participants:

 Description   

can we add a feature like regex replace which will find all occurrences of a regex pattern in a string field, and replace them with something generic. example use case -" replace all telephone numbers in a error message with X so that all of them can be group in a single bucket"

as of now i think there is no way of doing it other than handling it in client code.Please correct me if there is something already available that i am not aware of,



 Comments   
Comment by Kelsey Schubert [ 21/Feb/18 ]

Hi sourav_biswas@cable.comcast.com,

Thanks for the clarification. I believe SERVER-32314 tracks the feature that your looking for, and Asya recently posted an example of a workaround in that ticket that I would suggest reviewing. In addition, you may want to watch and vote for a related ticket, SERVER-11947, which would provide additional functionality.

Kind regards,
Kelsey

Comment by Sourav Biswas [ 20/Feb/18 ]

Sample

  1. { error : "got error for telephone 1111111111"}
  2. { error : "got error for telephone 2222222222"}
  3. { error : "got error for telephone 3333333333"}

Use case - when grouping on the field "error" i should get a count of 3 in a single group of "got error for telephone x".

So essentially there is will be a $project stage before the $group where we can apply some function like * $regexReplace : ["$error","[0-9]{10}","x"]*

Comment by Ramon Fernandez Marina [ 20/Feb/18 ]

Will you please provide a sample usage case with some input and output documents so we can have a clear idea of what exact functionality would help your use case?

Thanks,
Ramón.

Generated at Thu Feb 08 04:33:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.