[CSHARP-1650] Operator for splitting string based on a separator. Created: 05/May/16  Updated: 27/May/22  Resolved: 26/Aug/16

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: None
Fix Version/s: 2.4

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-6773 Aggregation operator $split for split... Closed
Epic Link: MongoDB 3.4
Server Compat: 3.3

 Description   

Syntax

{$split: [<expression>, <expression>]}

Examples

> db.coll.insert([
  {_id: 1, string: "abracadabra"}
]);
> db.coll.aggregate([{
  $project: {
    split: {$split: ["$string", "a"]}
  }
}]);
{_id: 1, split: ["", "br", "c", "d", "br", ""]}
 
// Example 2
> db.coll.insert([
  {_id: 1, string: "zero one zero zero one zero one"}
]);
> db.coll.aggregate([{
  $project: {
    split: {$split: ["$string", "one"]}
  }
}]);
{_id: 1, split: ["zero ", " zero zero ", " zero ", ""]}
 
 
// Example 3
> db.coll.insert([
  {_id: 1, string: "hello world"}
]);
> db.coll.aggregate([{
  $project: {
    split: {$split: ["$string", "notInTheString"]}
  }
}]);
{_id: 1, split: ["hello world"]}

Notes

  • Identical functionality as Python's split(), including the empty string being output if the pattern lies at the beginning or end of the string.

Errors

  • If either input expression does not evaluate to a string.

Old Description
It would be nice to have more operators for dealing with strings in the aggregation framework. A very useful operator would be a simple split to be used in the $project part of the pipeline.

If I could write something like:

{$project : {words : {$split : "$some_textual_field"}}

that would result in the string contained in the given field to be turned into a word list (based on whitespaces and punctuation signs, or maybe a regexp defining where to split).

This would be tremendously useful for natural language processing and similar tasks.



 Comments   
Comment by Githook User [ 29/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Combine if statements.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/0c8e3b3482a64a00152955ab88b7720ac107bb6e

Comment by Githook User [ 29/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Refactor implementation of Split translation.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/29fdc7623a590c410a15074631f5ef0bab780c35

Comment by Githook User [ 29/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1650: added support for $split.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/559749cc30ddc4fe0107fdf305992ba7969bc4ff

Comment by Githook User [ 24/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Combine if statements.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/0c8e3b3482a64a00152955ab88b7720ac107bb6e

Comment by Githook User [ 24/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Refactor implementation of Split translation.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/29fdc7623a590c410a15074631f5ef0bab780c35

Comment by Githook User [ 24/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1650: added support for $split.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/559749cc30ddc4fe0107fdf305992ba7969bc4ff

Comment by Githook User [ 21/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Combine if statements.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/0c08712393d87e79b7fe7ac76e403d2a81f4799b

Comment by Githook User [ 21/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Refactor implementation of Split translation.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/c5cb76ca04d823e76361c5ad59c844d97dbf0ff7

Comment by Githook User [ 21/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1650: added support for $split.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/b4f41e0fd5a9e0526df3fb39f1f4733231b7c44a

Comment by Githook User [ 16/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Combine if statements.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/840b98d03e2ec10afd0482e72f8a2b679e353ae0

Comment by Githook User [ 16/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Refactor implementation of Split translation.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/e750541b75ce31eaaca0676a4b457e75908d4b2d

Comment by Githook User [ 16/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1650: added support for $split.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/dceb22f4782576acd2c8d553faf1c23652c9cae9

Comment by Githook User [ 31/Aug/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Combine if statements.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/2aed43cba769abbcaf72640ab542a620e6f77507

Comment by Githook User [ 31/Aug/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Refactor implementation of Split translation.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/200366c984843134cae0824d1edb0f8aae757143

Comment by Githook User [ 31/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1650: added support for $split.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/c78797b042569c0b903b6f7188afefdb5bea9a47

Comment by Githook User [ 29/Aug/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Combine if statements.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/99bafd435dd361589c3dce48dfcd9136eab0edab

Comment by Githook User [ 29/Aug/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Refactor implementation of Split translation.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/3accd41d8945fe4c3b244b2a9f20bf4a857c7220

Comment by Githook User [ 29/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1650: added support for $split.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/caf9ee95145df53581efc64bb99a2914310a6e68

Comment by Githook User [ 26/Aug/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Combine if statements.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/07691733670c738ebdb5062bfe3b036027a5b96e

Comment by Githook User [ 26/Aug/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1650: Refactor implementation of Split translation.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/9a4df4806f88b00f8a0533103c3bd52fd5ecf20b

Comment by Githook User [ 26/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1650: added support for $split.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/5080f475d381f42a1f8d421a5671152907c83997

Generated at Wed Feb 07 21:40:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.