Docs Menu
Docs Home
/
MongoDB Atlas
/

Atlas Search 쿼리 생성 및 실행

이 페이지의 내용

  • 지원되는 클라이언트
  • 다음 단계

Atlas Search queries take the form of an aggregation pipeline stage. Atlas Search provides $search and $searchMeta stages, both of which must be the first stage in any query pipeline, including the $lookup and $unionWith sub-pipelines. These stages can be used in conjunction with other aggregation pipeline stages in your query pipeline. To learn more about these pipeline stages, see Choose the Aggregation Pipeline Stage.

Atlas Search also provides query operators and collectors that you can use inside the $search and $searchMeta aggregation pipeline stages. The Atlas Search operators allow you to locate and retrieve relevant data from the collection on your Atlas cluster. The collector returns a document representing the search metadata results.

You can use Atlas Search operators to query terms, phrases, geographic shapes and points, numeric values, similar documents, synonymous terms, and more. You can also search using regex and wildcard expressions. The Atlas Search compound operator allows you to combine multiple operators inside your $search stage to perform a complex search and filter of data based on what must, must not, or should be present in the documents returned by Atlas Search. You can use the compound operator to also match or filter documents in the $search stage itself. Running $match after $search is less performant than running $search with the compound operator.

Atlas Search 연산자의 구문, 옵션 및 사용법에 대한 자세한 내용은 Atlas Search 쿼리에서 연산자 및 수집기 사용을 참조하세요.

mongod and mongot on the Same Node

When you run a query, Atlas Search uses the configured read preference to identify the node on which to run the query. The query first goes to the MongoDB process, which is mongod for a replica set cluster or mongos for a sharded cluster.

For a replica set cluster, the MongoDB process routes the query to the mongot on the same node. For sharded clusters, your cluster data is partitioned across mongod instances and each mongot knows about the data on the mongod on the same node only. Therefore, you can't run Atlas Search queries that target a particular shard. mongos directs the queries to all shards, making these scatter gather queries. If you use zones to distribute a sharded collection over a subset of the shards in the cluster, Atlas Search routes the query to the zone that contains the shards for the collection that you are querying and runs your $search queries on just the shards where the collection is located.

Atlas Search performs the search and scoring and returns the document IDs and other search metadata for the matching results to mongod. The mongod then performs a full document lookup implicitly for the matching results and returns the results to the client. If you use the $search concurrent option in your query, Atlas Search enables intra-query parallelism. To learn more, see Parallelize Query Execution Across Segments.

mongod and mongot on Different Nodes

When you run a query, the query first goes to the mongod based on the configured read preference. The mongod process routes the search query through a load balancer on the same node, which distributes the requests across all of the mongot processes.

The Atlas Search mongot process performs the search and scoring and returns the document IDs and metadata for the matching results to mongod. The mongod then performs a full document lookup for the matching results and returns the results to the client. If you use the $search concurrent option in your query, Atlas Search enables intra-query parallelism. To learn more, see Parallelize Query Execution Across Segments.

Atlas Search는 결과 세트의 모든 문서에 관련성 기반 점수를 부여합니다. 관련성 기반 점수 매기기를 통해 Atlas Search는 가장 높은 점수에서 가장 낮은 점수 순서로 문서를 반환할 수 있습니다. Atlas Search는 쿼리어가 문서에 자주 나타나는 경우 문서 점수를 높이고 컬렉션의 여러 문서에 쿼리어가 나타나면 낮은 점수를 줍니다. Atlas Search는 또한 부스트, 감쇠(decaying) 또는 또는 기타 수정 옵션을 통해 관련성 기반의 기본 점수를 사용자 맞춤형으로 조정하는 것도 가능합니다. 결과 점수 사용자 지정에 대해 자세히 알아보려면 결과에서 문서 점수 매기기를 참조하세요.

참조 항목: 보면서 배우기

이 동영상에서 Atlas Search로 쿼리를 검색하고 추적하는 방법에 대한 개요를 확인하세요. 이 동영상에서는 Atlas Search 연산자에 대한 내용 및 결과에서 문서의 점수를 산정하는 방법에 대해 자세히 알아볼 수 있습니다.

지속 시간 소요 시간: 15분

You can create and run Atlas Search queries using the following:

To learn how to create and run a query, see Create a Query. For hands-on experience creating Atlas Search indexes and running Atlas Search queries against the sample datasets, try the tutorials in the following pages:

돌아가기

Update

다음

쿼리 생성