部分索引的局限性是什么? [英] What are the limitations of partial indexes?
问题描述
最新版本的MongoDB(v3.2)增加了对部分(已过滤)的支持指标的。您在创建索引时提供过滤器,并且该过滤器确定将在索引中引用哪些文档,哪些不会。
The latest version of MongoDB (v3.2) adds support for partial (filtered) indexes. You supply a filter when you create the index and that filter determines which documents will be referenced in the index and which will not.
我可以使用任何过滤器表达式(只要因为它是一个有效的过滤器)?或者使用过滤器有限制吗?如果是这样,那些限制是什么?
Can I use any filter expression (as long as it's a valid filter)? Or are there limitations to the filter being used? If so, what are those limitations?
推荐答案
我可以使用任何过滤器表达式吗?
Can I use any filter expression?
不,部分索引仅支持所用过滤器中的一部分运算符。唯一支持的运算符是: $ AND
(仅在顶级), $ EQ
, $ LT
, $ LTE
, $ GT
, $ GTE
, $ EXISTS
和 TYPE_OPERATOR
。
No, partial indexes support only a subset of the operators in the filter used. The only supported operators are: $AND
(only at the top level), $EQ
, $LT
, $LTE
, $GT
, $GTE
, $EXISTS
and the TYPE_OPERATOR
.
遗漏了,例如 $ NOT
, $ REGEX
, $ OR
等。
您可以在MongoDB的源代码中看到在其他地方。
You can see that in the source for MongoDB here.
有什么限制?
What are those limitations?
部分索引也有一些一般限制:
There are also some general limitations on partial indexes:
-
_id
索引不能是部分索引。 - 稀疏索引不能是部分索引索引。
- 分片键索引不能是部分索引。
- 3.2之前的版本不支持部分索引。
_id
indexes can't be partial indexes.- Sparse indexes can't be partial indexes.
- Shard key indexes can't be partial indexes.
- Partial indexes aren't supported in versions earlier than 3.2.
这篇关于部分索引的局限性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!