MongoDB.local SF, Jan 15: See the speaker lineup & ship your AI vision faster. Use WEB50 to save 50%
Find out more >
Docs Menu
Docs Home
/ /
인덱스 작업
/ / /

Atlas search 인덱스

Atlas Search 기능을 사용하면 MongoDB Atlas에서 호스팅되는 컬렉션에서 전체 텍스트 검색을 수행할 수 있습니다. Atlas Search 인덱스는 검색 동작과 인덱싱할 필드를 지정합니다.

컬렉션에서 다음과 같은 메서드를 호출하여 Atlas Search 인덱스를 관리할 수 있습니다.

  • createSearchIndex()

  • createSearchIndexes()

  • listSearchIndexes()

  • updateSearchIndex()

  • dropSearchIndex()

참고

Atlas Search 인덱스 관리 메서드는 비동기적으로 실행 , 성공적으로 실행되었는지 확인하기 전에 반환될 수 있습니다. 인덱스의 현재 상태를 확인하려면 listSearchIndexes() 메서드를 호출합니다.

다음 섹션에서는 코드 예시를 제공하여 이전의 각 메서드를 사용하는 방법을 보여줍니다.

createSearchIndex()createSearchIndexes() 메서드를 사용하여 하나 이상의 Atlas Search 인덱스를 만들 수 있습니다.

다음 코드 예시에서는 단일 인덱스를 생성하는 방법을 보여줍니다.

val index = Document("mappings", Document("dynamic", true))
collection.createSearchIndex("<index name>", index)

다음 코드 예시에서는 여러 인덱스를 생성하는 방법을 보여줍니다.

val indexOne = SearchIndexModel("<first index name>", Document("mappings", Document("dynamic", true)))
val indexTwo = SearchIndexModel("<second index name>", Document("mappings", Document("dynamic", true)))
collection.createSearchIndexes(listOf(indexOne, indexTwo))

Atlas Search 인덱스를 정의하는 데 사용되는 구문에 대해 자세히 알아보려면 Atlas 매뉴얼의 Atlas Search 인덱스 구문 검토 가이드를 참조하세요.

listSearchIndexes() 메서드를 사용하여 컬렉션의 모든 Atlas Search 인덱스를 반환할 수 있습니다.

다음 코드 예시에서는 컬렉션의 검색 인덱스 목록을 출력하는 방법을 보여줍니다.

val results = collection.listSearchIndexes()
results.forEach { result ->
println(result)
}

updateSearchIndex() 메서드를 사용하여 Atlas Search 인덱스를 업데이트할 수 있습니다.

다음 코드에서는 검색 업인덱스를데이트하는 방법을 보여줍니다.

val newIndex = Document("mappings", Document("dynamic", true))
collection.updateSearchIndex("<index to update>", newIndex)

dropSearchIndex() 메서드를 사용하여 Atlas Search 인덱스 삭제 수 있습니다.

다음 코드에서는 컬렉션에서 검색 인덱스를 삭제하는 방법을 보여줍니다.

collection.dropIndex("<index to delete>")

MongoDB Atlas Search에 대해 자세히 학습하려면 Atlas Search Indexes 문서를 참조합니다.

돌아가기

복합 인덱스

이 페이지의 내용