Skip to content

Commit

Permalink
Merge pull request #1413 from alcaeus/add-partial-index-examples
Browse files Browse the repository at this point in the history
Add docs example for partial indexes
  • Loading branch information
malarzm committed May 30, 2016
2 parents 1fdf2c7 + 933614c commit f88851d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions docs/en/reference/indexes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,61 @@ options structures manually:
keys:
coordinates: 2d
Partial indexes
---------------

You can create a partial index by adding a ``partialFilterExpression`` to any
index.

.. configuration-block::

.. code-block:: php
<?php
/**
* @Document
* @Index(keys={"city"="asc"}, partialFilterExpression={"version"={"$gt"=1}})
*/
class Place
{
/** @Id */
public $id;
/** @Field(type="string") */
public $city;
/** @Field(type="int") */
public $version;
}
.. code-block:: xml
<indexes>
<index>
<key name="city" order="asc" />
<partial-filter-expression>
<field name="version" value="1" operator="gt" />
</partial-filter-expression>
</index>
</indexes>
.. code-block:: yaml
indexes:
partialIndexExample:
keys:
coordinates: asc
options:
partialFilterExpression:
version: { $gt: 1 }
.. note::

Partial indexes are only available with MongoDB 3.2 or newer. For more
information on partial filter expressions, read the
`official MongoDB documentation <https://docs.mongodb.com/manual/core/index-partial/>`_.

Requiring Indexes
-----------------

Expand Down

0 comments on commit f88851d

Please sign in to comment.