AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

$bitsAnyClear(쿼리 자 연산자)

$bitsAnyClear

$bitsAnyClear matches documents where any of the bit positions given by the query are clear (i.e. 0) in field.

{ <field>: { $bitsAnyClear: <numeric bitmask> } }

{ <field>: { $bitsAnyClear: < BinData bitmask> } }

{ <field>: { $bitsAnyClear: [ <position1>, <position2>, ... ] } }

The field value must be either numeric or a BinData instance. Otherwise, $bitsAnyClear will not match the current document.

숫자 비트마스크

You can provide a numeric bitmask to be matched against the operand field. The bitmask must be a non-negative 64-bit signed integer. Otherwise, $bitsAnyClear returns an error.

BinData Bitmask

임의로 큰 BinData 인스턴스를 비트마스크로 사용할 수도 있습니다.

위치 목록

비트 위치 목록을 쿼리하는 경우 각 <position>은 음수가 아닌 정수여야 합니다. 비트 위치는 최하위 비트에서 0부터 시작합니다. 예를 들어 10진수 254의 비트 위치는 다음과 같습니다.
비트 값
1
1
1
1
1
1
1
0

직위

7

6

5

4

3

2

1

0

시스템의 엔디안 은 머신의 아키텍처에 따라 달라집니다. BSON 데이터의 숫자는 항상 리틀 엔디안 으로 저장되며, 시스템이 빅 엔디안 인 경우 숫자 데이터가 빅 엔디안과 리틀 엔디안 간에 변환됩니다.

비트 테스트 일치 표현식 연산자의 컨텍스트에서:

BinData 값은 비트마스크 역할을 하며 임의의 길이의 부호 없는 리틀 엔디안 숫자처럼 해석됩니다. 주소 지정 가능한 최하위 바이트는 항상 최하위 바이트로 해석됩니다. 마찬가지로 BinData 에서 주소 지정 가능한 가장 높은 바이트는 항상 최상위 바이트로 해석됩니다.

Queries cannot use indexes for the $bitsAnyClear portion of a query, although the other portions of a query can use indexes, if applicable.

$bitsAnyClear 는 부호 있는 64비트 정수로 표시할 수 없는 숫자 값과 일치하지 않습니다. 값이 너무 크거나 너무 작아서 부호 있는 64비트 정수에 맞지 않거나 분수 구성 요소가 있는 경우가 이에 해당할 수 있습니다.

Numbers are sign extended. For example, $bitsAnyClear considers bit position 200 to be set for the negative number -5, but bit position 200 to be clear for the positive number +5.

대조적으로 BinData 인스턴스는 0 확장됩니다. 예를 들어 다음 문서가 있다고 가정해 보겠습니다.

db.collection.insertOne({ x: BinData(0, "ww=="), binaryValueofA: "11000011" })

$bitsAnyClear will consider all bits outside of x to be clear.

다음 예시에서는 다음 문서와 함께 컬렉션을 사용합니다.

db.collection.insertMany([
{ _id: 1, a: 54, binaryValueofA: "00110110" },
{ _id: 2, a: 20, binaryValueofA: "00010100" },
{ _id: 3, a: 20.0, binaryValueofA: "00010100" },
{ _id: 4, a: BinData(0, "Zg=="), binaryValueofA: "01100110" }
])

The following query uses the $bitsAnyClear operator to test whether field a has either bit position 1 or bit position 5 clear, where the least significant bit is position 0.

db.collection.find( { a: { $bitsAnyClear: [ 1, 5 ] } } )

쿼리가 다음 문서와 일치합니다.

{ "_id" : 2, "a" : 20, "binaryValueofA" : "00010100" }
{ "_id" : 3, "a" : 20.0, "binaryValueofA" : "00010100" }

The following query uses the $bitsAnyClear operator to test whether field a has any bits clear at positions 0, 1, and 5 (the binary representation of the bitmask 35 is 00100011).

db.collection.find( { a: { $bitsAnyClear: 35 } } )

쿼리가 다음 문서와 일치합니다.

{ "_id" : 1, "a" : 54, "binaryValueofA" : "00110110" }
{ "_id" : 2, "a" : 20, "binaryValueofA" : "00010100" }
{ "_id" : 3, "a" : 20.0, "binaryValueofA" : "00010100" }
{ "_id" : 4, "a" : BinData(0,"Zg=="), "binaryValueofA" : "01100110" }

The following query uses the $bitsAnyClear operator to test whether field a has any bits clear at positions 4 and 5 (the binary representation of BinData(0, "MA==") is 00110000).

db.collection.find( { a: { $bitsAnyClear: BinData(0, "MA==") } } )

쿼리가 다음 문서와 일치합니다.

{ "_id" : 2, "a" : 20, "binaryValueofA" : "00010100" }
{ "_id" : 3, "a" : 20.0, "binaryValueofA" : "00010100" }
{ "_id" : 4, "a" : BinData(0,"Zg=="), "binaryValueofA" : "01100110" }
이 페이지 평가하기

이 페이지의 내용