On this page本页内容
Wildcard indexes do not support the following index types or properties:通配符索引不支持以下索引类型或属性:
Wildcard Indexes are distinct from and incompatible with Wildcard Text Indexes. 通配符索引与通配符文本索引不同,并且不兼容。Wildcard indexes cannot support queries using the 通配符索引不能支持使用$text operator.$text运算符的查询。
Wildcard indexes are sparse and do not index empty fields. 通配符索引是稀疏的,不为空字段编制索引。Wildcard indexes therefore cannot support querying for documents where a field does not exist.因此,通配符索引不支持查询字段不存在的文档。
For example, consider a collection 例如,考虑在inventory with a wildcard index on product_attributes. product_attributes上具有通配符索引的集合inventory。The wildcard index cannot support the following queries:通配符索引不能支持以下查询:
db.inventory.find( {"product_attributes" : { $exists : false } } )
db.inventory.aggregate([
{ $match : { "product_attributes" : { $exists : false } } }
])
Wildcard indexes generate entries for the contents of a document or array, and not the document/array itself. 通配符索引为文档或数组的内容生成条目,而不是文档/数组本身。Wildcard indexes therefore cannot support exact document/array equality matches. 因此,通配符索引不能支持精确的文档/数组相等匹配。Wildcard indexes can support querying where the field equals an empty document 通配符索引可以支持字段等于空文档{}.{}的查询。
For example, consider a collection 例如,考虑在inventory with a wildcard index on product_attributes. product_attributes上具有通配符索引的集合inventory。The wildcard index cannot support the following queries:通配符索引不能支持以下查询:
db.inventory.find({ "product_attributes" : { "price" : 29.99 } } )
db.inventory.find({ "product_attributes.tags" : [ "waterproof", "fireproof" ] } )
db.inventory.aggregate([{
$match : { "product_attributes" : { "price" : 29.99 } }
}])
db.inventory.aggregate([{
$match : { "product_attributes.tags" : ["waterproof", "fireproof" ] } }
}])
Wildcard indexes generate entries for the contents of a document or array, and not the document/array itself. Wildcard indexes therefore cannot support exact document/array inequality matches.通配符索引为文档或数组的内容生成条目,而不是文档/数组本身。因此,通配符索引不能支持精确的文档/数组不等式匹配。
For example, consider a collection 例如,考虑在inventory with a wildcard index on product_attributes. product_attributes上具有通配符索引的集合inventory。The wildcard index cannot support the following queries:通配符索引不能支持以下查询:
db.inventory.find( { $ne : [ "product_attributes", { "price" : 29.99 } ] } )
db.inventory.find( { $ne : [ "product_attributes.tags", [ "waterproof", "fireproof" ] ] } )
db.inventory.aggregate([{
$match : { $ne : [ "product_attributes", { "price" : 29.99 } ] }
}])
db.inventory.aggregate([{
$match : { $ne : [ "product_attributes.tags", [ "waterproof", "fireproof" ] ] }
}])
nullIf a given field is an array in any document in the collection, wildcard indexes cannot support queries for documents where that field is not equal to 如果给定字段是集合中任何文档中的数组,则通配符索引不能支持对该字段不等于null.null的文档的查询。
For example, consider a collection 例如,考虑在inventory with a wildcard index on product_attributes. product_attributes上具有通配符索引的集合inventory。The wildcard index cannot support the following queries if 如果product_attributes.tags is an array in any document in the collection:product_attributestags是集合中任何文档中的数组,则通配符索引无法支持以下查询:
db.inventory.find( { $ne : [ "product_attributes.tags", null ] } )
db.inventory.aggregate([{
$match : { $ne : [ "product_attributes.tags", null ] }
}])
You cannot shard a collection using a wildcard index. 不能使用通配符索引分割集合。Create a non-wildcard index on the field or fields you want to shard on. 在要分片的一个或多个字段上创建非通配符索引。For more information on shard key selection, see Shard Keys.有关分片关键点选择的详细信息,请参阅分片键。