-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Index Maintenance
-
Query Execution
-
Major Change
-
(copied to CRM)
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"}]}})
- is related to
-
SERVER-153 javascript sort helper for custom sorting / indexing
- Backlog
-
SERVER-3260 Prefix Indexes
- Backlog
-
SERVER-90 case insensitive index
- Closed