Skip to content

Dictionary Resolver ≥0.3.0

Licensed only

This feature requires an enterprise license.

The dictionary resolver is a key-value map, and it is referred to as just dict when specifying aspects in the schema. It must be provided a [string]:number object, and all string inputs are translated on a number range map which can then be resolved to a 2-dimensional radial embedding. The Dictionary resolver is used to represent numerical values that can also be represented by keys.

For example, a table of metals and their densities can be represented as [key=metal_name]: value=metal_density.

How It Works

Upon instantiation a list of keys and their respective values must be provided. When entries are added to the database, the entry should only contain the key, which during resolving is replaced by the corresponding value, and is then used create the embedding in a manner that is identical to the number resolver: the value is normalised to a [0, 1] range with respect to the min/max values present in the mapping. The normalised value is then mapped to an angle covering 1.5π radians (not a full circle), ensuring that values at opposite ends of the range are not given similar embeddings. The output is a two-dimensional vector of (cos θ, sin θ) coordinates, scaled by an optional multiplier.

Settings

Setting Type Default Description
values Object {[string]: number} (required) The set of valid key-value pairs. Keys must be unique.

Example

This example is a list of metals and their densities.

Creating the resolver

{
  "name": "metal",
  "type": "dict",
  "path": "$.metal",
  "settings": {
    "values": {
      "gold": 19.3,
      "platinum": 21.4,
      "aluminium": 2.7,
      "copper": 8.9,
      "iron": 7.9,
      "lead": 11.3,
      "magnesium": 1.7,
      "silver": 10.5
    }
  },
  "multiplier": 1.0
}

Usage

[
  { "id": "0000", "doc": { "metal": "gold" } },
  { "id": "0001", "doc": { "metal": "copper" } },
  { "id": "0002", "doc": { "metal": "lead" } },
  { "id": "0003", "doc": { "metal": "magnesium" } }
]