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.
-
As of today, the setting supports only six languages: Dutch (nl
), German (de
), Finnish (fi
), Danish (da
), Swedish (sv
) and Norwegian Bokmål (no
).
-
Note The attributes listed must have been defined by searchableAttributes
.
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'
]
]
]);
|
1
2
3
4
5
6
7
| index.set_settings({
decompoundedAttributes: {
de: [
'name'
]
}
})
|
1
2
3
4
5
6
7
8
9
| index.setSettings({
decompoundedAttributes: {
de: [
'name'
]
}
}).then(() => {
// done
});
|
1
2
3
4
5
6
7
| index.set_settings({
'decompoundedAttributes': {
'de': [
'name'
]
}
})
|
1
2
3
4
5
6
7
8
| let settings = Settings()
.set(\.decompoundedAttributes, to: [.german: ["name"]])
index.setSettings(settings) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
|
1
2
3
4
5
6
7
| IndexSettings settings = new IndexSettings();
settings.DecompoundedAttributes = new Dictionary<string, List<string>>
{
{"de", new List<string> {"name"}}
};
index.SetSettings(settings);
|
1
2
3
4
5
6
7
8
9
10
11
| Map<String, List<String>> decompoundedAttributes = new HashMap<>();
decompoundedAttributes.put(
"de",
Arrays.asList("name")
);
index.setSettings(
new IndexSettings()
.setDecompoundedAttributes(decompoundedAttributes)
);
|
1
2
3
4
5
| res, err := index.SetSettings(search.Settings{
DecompoundedAttributes: opt.DecompoundedAttributes(map[string][]string{
"de": {"description"},
}),
})
|
1
2
3
4
5
6
7
8
9
10
| val decompoundedAttributes = Map("de" -> List("name"))
client.execute {
changeSettings of "myIndex" `with` IndexSettings(
customSettings = Some(
Map(
"decompoundedAttributes" -> decompoundedAttributes
)
)
)
}
|
1
2
3
4
5
6
7
| val settings = settings {
decompoundedAttributes {
german { +"name" }
}
}
index.setSettings(settings)
|
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'
]
]
]);
|
1
2
3
4
5
6
7
8
9
10
11
12
| index.set_settings({
decompoundedAttributes: {
de: [
'name_de',
'description_de'
],
fi: [
'name_fi',
'description_fi'
]
}
})
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| index.setSettings({
decompoundedAttributes: {
de: [
'name_de',
'description_de'
],
fi: [
'name_fi',
'description_fi'
]
}
}).then(() => {
// done
});
|
1
2
3
4
5
6
7
8
9
10
11
12
| index.set_settings({
'decompoundedAttributes': {
'de': [
'name_de',
'description_de'
],
'fi': [
'name_fi',
'description_fi'
]
}
})
|
1
2
3
4
5
6
7
8
9
10
11
| let settings = Settings()
.set(\.decompoundedAttributes, to: [
.german: ["description_de", "name_de"],
.finnish: ["name_fi", "description_fi"]
])
index.setSettings(settings) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
|
1
2
3
4
5
6
7
8
| IndexSettings settings = new IndexSettings();
settings.DecompoundedAttributes = new Dictionary<string, List<string>>
{
{"de", new List<string> {"name_de", "description_de"}},
{"fi", new List<string> {"name_fi", "description_fi"}}
};
index.SetSettings(settings);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| Map<String, List<String>> decompoundedAttributes = new HashMap<>();
decompoundedAttributes.put(
"de",
Arrays.asList(
"name_de",
"description_de"
)
);
decompoundedAttributes.put(
"fi",
Arrays.asList(
"name_fi",
"description_fi"
)
);
index.setSettings(
new IndexSettings().setDecompoundedAttributes(decompoundedAttributes)
);
|
1
2
3
4
5
6
| res, err := index.SetSettings(search.Settings{
DecompoundedAttributes: opt.DecompoundedAttributes(map[string][]string{
"de": {"name_de", "description_de"},
"fi": {"name_fi", "description_fi"},
}),
})
|
1
2
3
4
5
6
7
8
9
10
11
12
| val decompoundedAttributes = Map(
"de" -> List("name_de", "description_de")
"fi" -> List("name_fi", "description_fi")
)
client.execute {
changeSettings of "myIndex" `with` IndexSettings(
customSettings = Some(
Map("decompoundedAttributes" -> decompoundedAttributes)
)
)
}
|