MongoDB中有没有类似ElasticSearch的路由的选项?

Is there any option similar to ElasticSearch's routing in MongoDB?

根据ElasticSearch路由参数文档,

When executing a search, it will be broadcasted to all the index/indices shards (round robin between replicas). Which shards will be searched on can be controlled by providing the routing parameter. For example, when indexing tweets, the routing value can be the user name.

In such a case, if we want to search only on the tweets for a specific user, we can specify it as the routing, resulting in the search hitting only the relevant shard.

$ curl -XGET 'http://localhost:9200/twitter/tweet/_search?routing=kimchy' -d '{
    "query": {
        "filtered" : {
            "query" : {
                "query_string" : {
                    "query" : "some query string here"
                }
            },
            "filter" : {
                "term" : { "user" : "kimchy" }
            }
        }
    }
}
'

因此,当我从 MongoDb 开始时,我正在寻找任何类似的选项(如果有的话)?

MongoDB 中的等效概念是 shard key。如果 mongos 可以从分片键确定只有部分(或一个)分片保存与查询相关的数据,则只会访问这些分片。