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

Add expression indexes

    • Query Execution
    • Major Change

      An expression index is one where the value being indexed is the result of an expression, like lower casing a string.

      http://en.wikipedia.org/wiki/Expression_index
      http://www.postgresql.org/docs/8.1/static/indexes-expressional.html

      One possible way of specifying the expression could be through the existing aggregation expressions: http://docs.mongodb.org/manual/reference/operator/aggregation/#arithmetic-operators

      db.coll.addIndex("lowercase_name", {$expression: {$toLower:"$name"}});
      

      Note: In the example above there is no name for the expression, aside from the index name, because any name could conflict with documents. Also, the expression should be used in the query; the query expression may be a sub/superset of the index expression, or multiple indexes.

      Any expression support in indexes requires those expressions be available in the query language as well; it could look like this:

      db.coll.find({$expression: {$eq:["scott", {$toLower:"$name"}]}})
      

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            18 Vote for this issue
            Watchers:
            41 Start watching this issue

              Created:
              Updated: