On this page本页内容
Wildcard indexes do not support the following index types or properties:通配符索引不支持以下索引类型或属性:
Note
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:通配符索引无法支持以下查询:
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:通配符索引无法支持以下查询:
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:通配符索引无法支持以下查询:
null
null
If 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_attributes.tags
是集合中任何文档中的数组,则通配符索引无法支持以下查询:
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.有关碎片关键点选择的详细信息,请参阅碎片关键点。