WL#10604: Create multi-value index

Affects: Server-8.0   —   Status: Complete

Motivation

Support for evaluating expressions involving document fields that are arrays of multiple values, with the possibility of creating indexes on them.

Goals

  • Ensuring 'cont_in' and 'not_cont_in' operators uses indexes.
  • Introducing a new function and/or operator that map to the new JSON_OVERLAPS() function (e.g. X overlaps Y).
  • Introducing a new kind of indexed field: "array".
  • Extending the index type with a CHAR(n) type for homogeneity.

Examples:

{"emails":["foo@bar.com", "info@bar.com"]}

"foo@bar.com" in $.emails --> true
"bla" in $.emails --> false
"bla" not in $.emails --> true

["foo@bar.com", "info@bla.com"] overlaps $.emails --> true

Indexing arrays require the type of the contents to be specified at the time of the index creation, besides specification that the index is on an array.

Example:

coll.createIndex("emails_idx", {fields: [{"field": "$.emails", "type":"CHAR(128)", "array": true}]});

Limitations

  • All array values must be of the same type and the type must be specified at the time the index is created
  • Only arrays of numeric, date and string values are allowed. Nested objects or arrays are not.
  • The index must always accept an empty array field. There is no possibility to create the NOT NULL index.