API Reference / API Parameters / decompoundedAttributes
Type: object
Engine default: (no decompounded attribute)
Parameter syntax
'decompoundedAttributes' => [
  ['2-character country code' => ['attribute', 'attribute']],
  ['2-character country code' => ['attribute', 'attribute']],
  ...
]

Can be used in these methods:

About this parameter

Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding.

A compound word refers to a word that is formed by combining smaller words without spacing.

They’re called noun phrases, or nominal groups, and are particularly present in Germanic and Scandinavian languages. An example is the German “Gartenstühle,” which is a contraction of “Garten” and “Stühle.”

The goal of decompounding, regarding the previous example, is to index both “Garten” and “Stühle” separately, instead of together as a single word. This way, if a user searches for “Stühle”, Algolia returns results with “Gartenstühle” and other “Stühle”, for example “Polsterstühle”, “Bürostühle”, etc.

Usage notes

  • You can specify different attributes for each language.
  • Attribute names are case-sensitive.
  • The attributes must be included in the searchableAttributes setting.
  • Decompounding is supported for:
    • Danish (da)
    • Dutch (nl)
    • Finnish (fi)
    • German (de)
    • Norwegian (no)
    • Swedish (sv)
  • Decompounding is not supported for words that contain non-spacing mark Unicode characters. For example, Gartenstühle would not be decompounded if this is actually made of u (U+0075) + ◌̈ (U+0308).

Examples

Enable word decompounding for one language

This example considers an index having only one language (de) and where the goal is to decompound only the attribute name.

1
2
3
4
5
6
7
$index->setSettings([
  'decompoundedAttributes' => [
    'de' => [
      'name'
    ]
  ]
]);

Enable word decompounding for several languages

This example considers an index containing two languages (de, fi) in different attributes and where the goal is to decompound name and description for both languages.

1
2
3
4
5
6
7
8
9
10
11
12
$index->setSettings([
  'decompoundedAttributes' => [
    'de' => [
      'name_de',
      'description_de'
    ],
    'fi' => [
      'name_fi',
      'description_fi'
    ]
  ]
]);
Did you find this page helpful?