HomeDev GuideAPI Reference
Dev GuideAPI ReferenceLegal TermsDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Language routing

Describes language routing in Optimizely Search & Navigation.

The language routing feature limits search queries to documents in a specified language.

Language routing makes querying more precise by reducing the number of false positive matches because it analyzes documents for only one language. Because language routing optimizes indexing performance and increases query precision, you should use it when indexing documents. Language routing requires no change to search queries.

Previously, Optimizely Search & Navigation analyzed documents for supported languages. This practice sometimes caused noise when one language's stemming rules collided with another's.

Add language routing on any type of object

You can add language routing to any type of object with the LanguageRoutingAttribute or the conventions API.

LanguageRoutingAttribute

You can add language routing with the LanguageRoutingAttribute on the property. Set it to the desired language when initializing the object.

public class WithLanguageRoutingAttribute {
  [Id]
  public string Id {
    get;
    set;
  }
  [LanguageRouting]
  public LanguageRouting LanguageRouting {
    get;
    set;
  }
}

var indexedObject = new WithLanguageRoutingAttribute() {
  Id = "123",
    LanguageRouting = new LanguageRouting(Language.Swedish)
};

Conventions

Another option is to use the conventions API in Search & Navigation.

client.Conventions.ForInstancesOf<WithLanguageRouting>().LanguageRoutingIs(x => x.LanguageRouting);

📘

Note

After upgrading to Optimizely Search & Navigation 13, reindex the whole site as soon as possible.