[DOCS-11536] Reverse byte positions match order of bitwise query by positions Created: 03/Apr/18 Updated: 30/Oct/23 Resolved: 03/Apr/18 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | None |
| Fix Version/s: | Server_Docs_20231030 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sin | Assignee: | Stennie Steneker (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: | |
| Days since reply: | 5 years, 45 weeks, 1 day ago |
| Description |
|
According to the comments in source code, the steps of matching BinData by bitwise query is:
That means, given the documents:
the query
matchs
and
matches
It's very counterintuitive and makes bitwise query operators much less useful. This behavior is also not clearly documented in the MongoDB Docs. |
| Comments |
| Comment by Sin [ 04/Apr/18 ] |
|
The document only explains the behavior within one byte, but not clearly explains the situation of multiple bytes. E.g., according to the document, we expect the positions like this:
However, the actual behavior is:
|
| Comment by Stennie Steneker (Inactive) [ 03/Apr/18 ] |
|
Since BSON types must be serialized in little endian format, the least significant bit comparison matches the BSON representation and ensures consistent cross-platform comparison. This behaviour is documented for the $bitsAnySet query operator:
Regards, |