[SERVER-14210] Using regex with the $and operator on the same field more than once Created: 09/Jun/14 Updated: 10/Dec/14 Resolved: 09/Jun/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.6.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Eriol Gjergji | Assignee: | David Storch |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL | |||||||||||||||||||||||||||||||||
| Steps To Reproduce: | I have a simple array of strings within a document, which is indexed, next I do this:
On the explain I get this:
but if I put the $or instead of $and I get this:
Im querying the same document and the same array on both cases |
|||||||||||||||||||||||||||||||||
| Participants: |
| Description |
|
Hello, not sure if this is an issue, but I didn't found anything useful on the docs... can I query same field using regex and $and operator? when I add the explain() I dont see the second regex shown there |
| Comments |
| Comment by Eriol Gjergji [ 09/Jun/14 ] | |||||||||||||||||||||||||||||||||||
|
Hey Dave, Thanks, | |||||||||||||||||||||||||||||||||||
| Comment by David Storch [ 09/Jun/14 ] | |||||||||||||||||||||||||||||||||||
|
Hi eriol, Yes, it is perfectly valid to use the $and operator with two regexes over the same field:
Note that the matching document gets returned as expected, even though the index bounds include only the Mercedes regex. The reason that the index bounds look odd is an internal detail of how the query planner constructs bounds for multikey indices. Since the matching documents have multiple index keys, the query execution must proceed as follows:
I'm closing as Works as Designed, as this is expected behavior. I hope the explanation was helpful, and please let me know if you have further related questions. Best, |