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.
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.
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.