Skip to content

Support object values in secondary indices #2773

Open

Description

@deontologician

Currently, something like this fails:

r.db('test').tableCreate('hams');
r.db('test').table('hams').indexCreate('bacon');
r.db('test').table('hams').insert({bacon: {crispy: true, salty: true}});
r.db('test').table('hams').getAll({crispy: true, salty: true}, {index: 'bacon'});

with:

RqlRuntimeError: Secondary keys must be a number, string, bool, or array (got {
    "crispy":   true,
    "salty":    true
} of type OBJECT) in:
r.db("test").table("hams").getAll({crispy: true, salty: true}, {index: "bacon"})

I ran into this limitation and @mlucy mentioned there was no technical reason objects aren't supported in secondary indexes.

Activity

  1. neumino commented on Jul 29, 2014

    @neumino
    Member

    Related to #1032

  2. added this to the subsequent milestone on Jul 30, 2014
  3. danielmewes commented on Jul 30, 2014

    @danielmewes
    Member

    Note to whoever will take this issue:
    We also decided to treat geometry (PTYPE<GEOMETRY>) like objects in (non-geo) secondary indexes.
    In daniel_geo trying to use a geometry object as a secondary index key currently fails in datum_t::pt_to_str_key(). Once we have support for converting objects to secondary index keys, we should use that same function in that place as well (though with a different prefix to maintain between-types ordering).
    Feel free to assign the transfer to geometry pseudo types to me once the code for handling objects is there.

  4. thelinuxlich commented on Aug 15, 2014

    @thelinuxlich

    +1

  5. stuartpb commented on Apr 24, 2015

    @stuartpb

    there was no technical reason objects aren't supported in secondary indexes.

    Isn't there? How would object values sort for orderBy?

  6. mlucy commented on Apr 24, 2015

    @mlucy
    Member

    You can already compare objects in ReQL with the normal comparator operators. We order the keys lexicographically and compare them key by key (where the absence of a key is considered to be smaller than any value for that key).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions