Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9639

2dsphere indexes with {2dsphereIndexVersion:2} should be sparse on geo fields

    • Major Change
    • ALL

      Starting in 2.6.0-rc0, there are two versions of 2dsphere indexes. All new 2dsphere indexes starting in 2.6.0-rc0 are created with {2dsphereIndexVersion:2}. The V2 behavior is consistent with the behavior of 2d indexes with regards to 'sparseness'

      {2dsphereIndexVersion: 1} indexes:

      • Do not support new GeoJSON geometries introduced in 2.5.0: (MultiPoint, MultiLineString, MultiPolygon,
        GeometryCollection).
      • Are not sparse and do not recognize the {sparse: true}

        index modifier.

      • Documents which contain null or "empty" [] for the geo field are rejected and not inserted into the collection.
      • Documents with the geo field undefined are indexed and added to the collection.
      • It is possible to preserve the V1 behavior by indicating the version when creating the index. See SERVER-12175.
        For example, coll.ensureIndex( {geo: "2dsphere"}, {"2dsphereIndexVersion": 1});

      {2dsphereIndexVersion: 2} indexes:

      • Ignore the sparse flag and print a warning to the server log if it's set.
      • If a document lacks a 2dsphere-indexed field (or the field is null or an empty array) the document is inserted but not added to the index.

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Original Ticket Description
      2dsphere indexes does not honor the sparse option. By contrast, 2d indexes are "sparse" by default and require all the fields from the index definition to be present in the document for the document to be included in the index.

      Don't know if this is an oversight or by design, but sparse functionality for 2dsphere is usable in the same way as sparse is usable for "normal" indexes.

            Assignee:
            hari.khalsa@10gen.com hari.khalsa@10gen.com
            Reporter:
            jhn Johan Hedin
            Votes:
            2 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: