드라이버가 포함된 MongoDB
정의
db.collection.getIndexes()숨겨진 인덱스와 현재 빌드 중인 인덱스를 포함하여 컬렉션 의 기존 인덱스를 식별하고 설명하는 문서 목록이 포함된 배열 반환합니다.
You must call
db.collection.getIndexes()on a collection. For example:db.collection.getIndexes() collection을 인덱스 정보를 반환할 collection의 이름으로 변경합니다.
호환성
이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
참고
이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
행동
Atlas search 인덱스
getIndexes() does not return information on Atlas Search indexes. For information on Atlas Search indexes, use $listSearchIndexes.
클라이언트 연결 해제
If the client that issued db.collection.getIndexes() disconnects before the operation completes, MongoDB marks db.collection.getIndexes() for termination using killOp.
복제본 세트 구성원 국가 제한
복제본 세트 노드에서 실행하는 경우 listIndexes 연산을 수행하려면 노드가 PRIMARY 또는 SECONDARY 상태여야 합니다. 노드가 STARTUP2와 같은 다른 상태이면 연산 오류가 발생합니다.
와일드카드 인덱스
MongoDB 6.3, 6.0.5 및 5.0.16부터 wildcardProjection 필드는 인덱스 프로젝션을 제출된 형식으로 저장합니다. 이전 버전의 서버에서는 프로젝션을 정규화된 형태로 저장했을 수 있습니다.
The server uses the index the same way, but you may notice a difference in the output of the listIndexes and db.collection.getIndexes() commands.
필요한 액세스 권한
To run db.collection.getIndexes() when access control is enforced, users must have privileges to listIndexes on the collection.
The built-in role read provides the required privileges to run db.collection.getIndexes() for the collections in a database.
출력
db.collection.getIndexes() 컬렉션에 대한 인덱스 정보를 담고 있는 문서 배열을 반환합니다. 예시:
[ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" }, { "v" : 2, "key" : { "status" : 1 }, "name" : "status_1" }, { "v" : 2, "key" : { "points" : 1 }, "name" : "points_1" } ]
인덱스 정보에는 인덱스 생성에 사용된 키와 옵션이 포함됩니다. 인덱스 옵션 hidden은 값이 true인 경우에만 사용할 수 있습니다.
키 및 인덱스 옵션에 대한 자세한 내용은 db.collection.createIndex()을(를) 참조하세요.