# attributes.json

What each attribute value means.

## `attributes`

array of objects

What an attribute's values mean: their type, unit, known values and how they are used. Facets are laid out in `categories.json`, searched fields in `types.json`.

- `code` (string · required): The code of an attribute definition, such as `color` or `seat_height`. The reserved words `any`, `all`, `not`, `category`, `brand`, `price`, `on_sale`, `availability`, `delivery_days` and `rating` cannot be attribute codes.

- `type` (string · required): - `boolean`
  
  - `text`: Free text: searchable, never a filter.
  
  - `identifier`: GTIN, MPN, ISBN and similar: exact match after normalization.
  
  - `option`: Enumerated values with labels, aliases, order, groups and swatches.
  
  - `number`: A number without a unit.
  
  - `quantity`: A number with a unit of one dimension.
  
  - `range`: A minimum and a maximum with a unit, such as age 3 to 6.
  
  - `date`: A date or a point in time.

- `label` (string or map of strings): A plain value, or a map from locale to value such as \{ "de": "Farbe", "en": "Color" \}.

- `level` (string): Whether the value belongs to the product or differs per variant. Default: `product`.
  
  - `product`: Whether the value belongs to the product or differs per variant. Default: `product`.
  
  - `variant`: Whether the value belongs to the product or differs per variant. Default: `product`.

- `multiple` (boolean): The value is a list, such as several materials.

- `localized` (boolean): The value differs per locale. For `text` and, rarely, `option`.

- `unit` (string): Quantities and ranges: the one canonical unit every value is converted to.
  
  - `mm`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `cm`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `m`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `in`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `ft`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `g`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `kg`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `lb`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `oz`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `ml`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `l`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `w`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `kw`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `wh`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `kwh`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `mah`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `v`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `lm`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `kelvin`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `celsius`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `hz`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `mb`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `gb`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `tb`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `day`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `month`: Quantities and ranges: the one canonical unit every value is converted to.
  
  - `year`: Quantities and ranges: the one canonical unit every value is converted to.

- `precision` (integer): Numbers, quantities and ranges: the decimal places shown.

- `values` (array of objects): Options: the known values, in display order. Their aliases merge other spellings into them; a value nobody listed becomes a value of its own and a merge suggestion in the panel, so nothing is dropped.
  
  A known value of an option attribute.
  
  - `code` (string · required): The code of an option value or option group, such as `grey` or `160x230`.
  
  - `label` (string or map of strings): A plain value, or a map from locale to value such as \{ "de": "Farbe", "en": "Color" \}.
  
  - `aliases` (array of strings): Spellings that mean this value, matched without regard to case, such as `Rot` and `rouge` for `red`.
  
  - `slug` (string or map of strings): Its word in URLs, per locale, such as `anthrazit`. It is made from the label when the value is created and stays when the label changes, so a URL that holds it never moves by accident. A release that leaves it out has it made from the label at every run, and the run report names it.
  
  - `slug_aliases` (array of strings or map of arrays of strings): The slugs it had before, per locale: a URL that holds one is read as the value and leads to its slug. A write that changes the slug keeps the old one here; deleting one is deliberate.
  
  - `group` (string or array of strings): The group or groups the value is shown under.
  
  - `swatch` (string): A swatch color in hexadecimal notation, such as `#C62828`.
  
  - `image` (string): A swatch image, such as a pattern or a mix of colors that no single color shows; its URL.
  
  - `description` (string or map of strings): What the value means, shown under it in a facet and read with it, such as "Coated fabric with the look of leather".

- `groups` (array of objects): Options: groups that show different values under one filter, such as burgundy and red under Red.
  
  Values shown under one filter. A selector naming a group means every value in it; a code that is both a value and a group means the group.
  
  - `code` (string · required): The code of an option value or option group, such as `grey` or `160x230`.
  
  - `label` (string or map of strings): A plain value, or a map from locale to value such as \{ "de": "Farbe", "en": "Color" \}.
  
  - `aliases` (array of strings): Words in a query that mean the group, such as `grau` for grey.
  
  - `slug` (string or map of strings): Its word in URLs, per locale, such as `anthrazit`. It is made from the label when the value is created and stays when the label changes, so a URL that holds it never moves by accident. A release that leaves it out has it made from the label at every run, and the run report names it.
  
  - `slug_aliases` (array of strings or map of arrays of strings): The slugs it had before, per locale: a URL that holds one is read as the value and leads to its slug. A write that changes the slug keeps the old one here; deleting one is deliberate.
  
  - `swatch` (string): A swatch color in hexadecimal notation, such as `#C62828`.
  
  - `image` (string): A swatch image, such as the pattern that stands for "mixed colors"; its URL.
  
  - `description` (string or map of strings): What the group holds, shown under it in a facet and read with it.

- `color_groups` (boolean): Options: the import places values that have no group in a color group, by the built-in color words and by their swatch. An attribute without groups of its own has the built-in ones.

- `filterable` (boolean): Selectors, filters and facets may use the attribute. Changing it needs an index run.

- `sortable` (boolean): Sort options may use the attribute. Changing it needs an index run.

- `detect_in_query` (boolean): The query is searched for the attribute's values, so "grauer teppich" filters on grey.

- `source_names` (array of strings): Column names the import maps onto this attribute, in any language.

## `$schema`

string

The JSON Schema an editor checks this file against; kept as written.

## Example

```json title="tests/fixtures/home/attributes.json (trimmed)"
{
  "$schema": "../../../contracts/schema/attributes.json",
  "attributes": [
    {
      "code": "color",
      "type": "option",
      "label": { "de": "Farbe", "en": "Color" },
      "level": "variant",
      "values": [
        {
          "code": "white",
          "label": { "de": "Weiß", "en": "White" },
          "aliases": ["weiß"],
          "slug": { "de": "weiss", "en": "white" },
          "group": "white",
          "swatch": "#FFFFFF"
        }
      ],
      "groups": [
        {
          "code": "white",
          "label": { "de": "Weiß", "en": "White" },
          "aliases": ["weiß"],
          "slug": { "de": "weiss", "en": "white" },
          "swatch": "#FFFFFF"
        }
      ],
      "color_groups": true,
      "filterable": true
    }
  ]
}
```

**Guide:** [Types and attributes](/docs/types-and-attributes#attributes)
