Skip to content

"Don't index this row" value for secondary indexes #4121

Open

Description

@stuartpb

As suggested in #1032 (comment) and the next ~7 replies after it, this would be a way of providing a value to skip indexing a row for index expressions, rather than just relying on errors or the (soon to be changed) unindexed behavior of null.

Activity

  1. added this to the subsequent milestone on Apr 24, 2015
  2. danielmewes commented on Apr 24, 2015

    @danielmewes
    Member

    Thanks for opening a separate issue. We'll discuss and schedule this together with #1032 once we have the time.

  3. stuartpb commented on Apr 24, 2015

    @stuartpb
    Author

    Another reason I think the value for this should be undefined/r.absent is because it would make the behavior of simple indexes in the absence of a field that much more predictable/straightforward to reason about. (absent being a suggestion from #1032 (comment))

    Also, absent makes sense for use in querying as well, both for getting the set of all rows that do not have a value for an index (like #1032 (comment) described for null back when null had the semantics of this proposed value), or for (possibly future use) more complex query/filter expressions where all documents that do have a field should be excluded (could be inverted and rewritten to not(hasFields()) by the driver or implementation).

  4. mike-marcacci commented on May 8, 2015

    @mike-marcacci

    This is a very interesting idea to me. It seems to me that a value of r.absent might also serve to remove a key from a record: .update({foo: r.absent}) instead of .replace(r.row.without('foo'))? If this were the case, such a value would have to be distinct from the language's concept of undefined.

  5. AtnNn commented on May 8, 2015

    @AtnNn
    Member

    a value of r.absent might also serve to remove a key from a record

    An empty r.literal already does this:

    >>> r.expr({a: 1, b: 2}).merge({a: r.literal()})
    {"b": 2}
    
  6. VeXocide commented on May 8, 2015

    @VeXocide
    Member

    PostgreSQL allows a CREATE INDEX name ON table WHERE predictate, could we do something similar with a function returning a boolean indicating whether or not to include a row in the index?

  7. mike-marcacci commented on May 8, 2015

    @mike-marcacci

    Wow, I had never used r.literal() without a value (usually a nested objected with some omitted keys)... I learn something new every time I comment! :)

  8. danielmewes commented on May 8, 2015

    @danielmewes
    Member

    @VeXocide I think we would probably not have a separate function, but have it part of the index function. Unless there's a good reason for having it separate.

    You can already do this with something like
    function (x) { return r.branch(predicate(x), x('field'), null) }

    With this proposal that would become
    function (x) { return r.branch(predicate(x), x('field'), r.absent) }

    I think that's nicer than a second function because it's more generic and doesn't add another argument to indexCreate. I might be wrong of course.

  9. VeXocide commented on May 8, 2015

    @VeXocide
    Member

    @danielmewes -- I agree r.absent is nicer here, you can ignore my previous proposal.

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