IndexSettings settings = new IndexSettings();
settings.DecompoundedAttributes = new Dictionary<string, List<string>>
{
{"2-character country code", new List<string> {"attribute", "attribute"}},
{"2-character country code", new List<string> {"attribute", "attribute"}}
};
Map<String, List<String>> decompoundedAttributes = new HashMap<>();
decompoundedAttributes.put(
"2-character country code",
Arrays.AsList(
"attribute",
"attribute"
)
);
decompoundedAttributes.put(
"2-character country code",
Arrays.AsList(
"attribute",
"attribute"
)
);
...
new IndexSettings().setDecompoundedAttributes(decompoundedAttributes)
opt.DecompoundedAttributes(map[string][]string{
"2-character country code": {"attribute", "attribute"},
"2-character country code": {"attribute", "attribute"},
...
})
val decompoundedAttributes = Map(
"2-character country code" -> List("attribute", "attribute")
"2-character country code" -> List("attribute", "attribute")
...
)
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).
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.