Info
db.wd_data.find({"path":{"$in":[/^\/PersonalWx\/Wx3001\/A李鑫老师助理6965号刘赫楠\/WxTxl\/三119扫单D!nG先生Super7李先生\//]}}
vs
db.wd_data.find({"path":{"$in":[/^\/PersonalWx\/Wx3001\/A李鑫老师助理6965号刘赫楠\/WxTxl\/三119扫单D!nG|先生Super7李先生\//]}}
the difference is the first one has no "|" in the query string, the second one does.
I will attach the explain() info, they show the difference
Top User Comments
dancer commented on Wed, 5 Jul 2017 09:01:00 +0000:
Since the issue is not fixed,I suggest user who want to match prefix to use "$gte + $lt" instead of regex.
thomas.schubert commented on Wed, 28 Jun 2017 12:31:44 +0000:
Hi dancer,
Thanks for the clarification. After review, we are going to continue to track this work in SERVER-16622. For additional context, please see SERVER-20432, which describes the same issue as this ticket and points to SERVER-16622 as well.
David Storch's comment clarifies this decision:
After reviewing this ticket, the engineering team responsible for the "Querying" component has decided to consider this a duplicate of SERVER-16622. Fixing the backslash-escaped "|" character case makes sense to do as part of the larger ticket, as this will require parsing the regular expression and analyzing the parse tree. From an engineering perspective, we would much rather use proper regex parsing than introduce a hack that special cases the string "|".
Kind regards,
Thomas
dancer commented on Wed, 28 Jun 2017 03:32:04 +0000:
I have viewed the previous issue, But I don't think it is a duplicated issue.
In my case, regexes was used to match prefix."|" was escaped(just a normal character),but mongodb still scan the whole index.
So it might be a new bug..
thomas.schubert commented on Wed, 28 Jun 2017 03:00:53 +0000:
Hi dancer,
Thank you for reporting this issue. The work to improve this behavior is tracked in SERVER-16622. Please feel free to vote for SERVER-16622 and watch it for updates.
Kind regards,
Thomas