HomeGuidesAPI ReferenceGraphQL
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

Breaking changes for Optimizely Search & Navigation 15

Breaking changes for Optimizely Search & Navigation in relation to version 14, and the steps needed to update affected code.

Wildcard prefix searches is no longer supported.

Before Optimizely Search & Navigation Client API version 15, you could search for documents with terms with an unknown beginning of the string.

This is no longer supported, but depending on the use case, you might be able to achieve the same results using different solutions.

If there is specific term field in your documents that you want to do wildcard prefix searches for, you can simply add a new property on your class that contains the reverse string of the regular field, then use a wildcard search and search for the reverse substring.

For example, you have the terms "cellphone" and "mobilephone" in a specific field in your documents, and you want to search for all documents containing "*phone":

Your class might then look like the following:

public class Phone {
    public string Name { get; set; }
    public string NameReverse
    {
        get => new(Name.Reverse().ToArray());
        set {; }
    }
}

Then index your data, and you can search in reverse using something like:

var search = "phone";
var searchReverse = new(search.Reverse().ToArray());

var result = client.Search<Phone>()
    .For(searchReverse + "*")
    .InField(x => x.NameReverse)
    .GetResult();

The indexed data in the field will then be:
enohpllec
enohpelibom

and search term will be :
enohp*

and will match both documents

If your use case is to search for wildcard prefixed words within a text, you have to make use of a different design of your code, like extracting the terms of interest and add them to a new field as described above.