Grasping right hand truncation (Girig högertrunkering) on all fields


We are converting from SiteSeeker to EPiServer Find for a customer and I notised that they are using something in SiteSeeker called (Girig högertrunkering) witch means that it instead of searching only for [Hell] it does a [Hell] OR [Hell*] -search. Read more here :

I have looked into the solutions for achiving this in EPiServer Find and in all of them it's only for one property, I want to do it for all properties and for information in files and so on.

Is there even possible to do that in EPiServer Find?



Oct 21, 2013 16:01

It should be since EPiServer has ElasticSearch that uses Solr and Lucene inside and Lucene supports it.

You can use Lucene Query Syntax (search text box is exposed in EPiServer Find CMS User Interface to let your try it out).

I guess the question is to get EPiServer Find to construct the query for you since it create an abstracts layer on top?

Oct 24, 2013 16:02

Fredrik Haglund. You are right, the searches worked in the admin-textbox, for example prestigel* did find a object containing the word prestigelös. 

When I try it in code like this:

var searchQuery = SearchClient.Instance.Search<Jobbannons>(Language.Swedish)
.For(query + "*")

It does not work, so I guess that you are right that the CMS are not supporting it on its abstracts layer. So the remaining question is how to get it to do that.

Oct 28, 2013 9:10

Looking into it a littel more I see in Fiddler that the CMS-integration escapes my "*" before it sends it the the find-server.
Searching for the same thing in admin gives this query to the server (tooked out only the important stuff)

Doing it with For and SearchClient like this (.For("prestigel*")) gives the following query

As you can see, the accual query sent through the form is prestigel\* not prestigel*

Maby it's a bug in Find or a feature, I don't know....


Oct 28, 2013 9:58

I got some answer from Joel in this article:

I tried to do his solution and it worked but, it still is per property and even if I know it's might be a stupid thing to do, I wan't it om all properties, exactly as it works in admin

Oct 28, 2013 11:18

I solved this myself by digging a little in the Find-dll'files.

It turned out that the ".For(" search method I am using a function called .Quote() to remove varius characters with \-sign. It is using this regexp:

static QueryEscaping()
QueryEscaping.SpecialCharactersRegex = new Regex("(\\+|\\-|\\&\\&|\\|\\||\\!|\\{|\\}|\\[|\\]|\\^|\\(|\\)|\\~|\\:|\\;|\\\\|\\?|\\*)", RegexOptions.Compiled);
QueryEscaping.QuotesRegex = new Regex("\\\"", RegexOptions.Compiled);
QueryEscaping.EvenNumberOfQuotes = new Regex("^(([^\"]*\"){2})*[^\"]*$", RegexOptions.Compiled);


I ended up creating a extendmethod that I named RightHandTruncationFor that does not replace these characters and puts a trailing * on the search string.

Here is the code:

public static IQueriedSearch<TSource, QueryStringQuery> GraspingRightHandTruncationFor<TSource>(this ITypeSearch<TSource> search, string queryString)
if (search == null)
throw new ArgumentNullException("search");

var str = (string.IsNullOrWhiteSpace(queryString) ? "" : queryString) + "*";

return new Search<TSource, QueryStringQuery>(search, (ISearchContext context) =>
var queryStringQuery = new QueryStringQuery(str);
context.RequestBody.Query = queryStringQuery;

if (context.RequestBody.Query != null)
var boolQuery = new BoolQuery();
boolQuery.MinimumNumberShouldMatch = 1;
context.RequestBody.Query = boolQuery;
context.RequestBody.Query = queryStringQuery;


Oct 28, 2013 11:48

Using Find 11 now and still no built in support for this...

Feb 23, 2016 18:46
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.