[COMPASS-3120] No support for negative regex, { $not: /regex/ } not accepted in query bar Created: 09/Sep/18 Updated: 29/Oct/23 Resolved: 24/Mar/20 |
|
| Status: | Closed |
| Project: | Compass |
| Component/s: | Compass, Grammar, Query Bar |
| Affects Version/s: | 1.15.1 |
| Fix Version/s: | 1.22.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Brian Blevins | Assignee: | Durran Jordan |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | query-parser | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Epic Link: | COMPASS-3417 | ||||||||||||||||
| Sprint: | Iteration Zebra | ||||||||||||||||
| Description |
|
In the mongo shell, the $not operator is allowed and documented for use against regular expressions. db.inventory.find( { item: { $not: /^p.*/ } } ) However, the Compass query bar does not accept this query. Please refer to the screenshots with both standard regex expression and $regex.
|
| Comments |
| Comment by Brian Blevins [ 18/Jan/19 ] |
|
To find all documents where the start station name does not contain "Ave", you can use the following: { 'start station name': { $regex: '^((?!Ave).)*$' }} The example from the description of this ticket above can be expressed in Compass as: { 'item': { $regex: '^((?!^p).)*$' }} Please refer to the documentation on $regex and PCRE vs Javascript for more information on the regular expressions accepted by $regex. Since reasoning about negative lookahead in regular expressions can be challenging, very thorough testing of this mechanism recommended.
|
| Comment by Randy Raymond [X] [ 07/Nov/18 ] |
|
I am glad this is here. I have been trying to run my query and wondered why it was not working. |
| Comment by Anna Herlihy (Inactive) [ 12/Sep/18 ] |
|
This will go away when language-modes is implemented, but that likely won't be for another quarter or two so we can document this in the meantime. |