What are the limitations of partial indexes?

半城伤御伤魂 提交于 2019-12-01 05:09:56

Can I use any filter expression?

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.

That leaves out, for example $NOT, $REGEX, $OR, etc.

You can see that in the source for MongoDB here.

What are those limitations?

There are also some general limitations on partial indexes:

  • _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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!