I'm working with Sitecore 10.1 and SOLR 8.4.0.

I am building a typeahead search that matches items (around 17,000) within a bucket in Sitecore. There are two fields in my template that can be matched, both are single-line text.

Because this is a typeahead suggest, I'm using StartsWith in my LINQ query.

using (var ctx = ContentSearchManager.GetIndex(searchIndex).CreateSearchContext()) {
    var query = ctx.GetQueryable<SearchResultItem>()
        .Where(i => i.TemplateId == SitecoreDefinitions.TypeAheadTemplateId &&
                    (i["display_name"].StartsWith(q) || i["alias"].StartsWith(q)));
    // handle results

The code above works great until there is a dash or a space in the query, at which point it doesn't treat them literally.

For example, if I look up Throat Can my expectation is that it will find "Throat Cancer" as a result. This is the SOLR query I see in the Search log:

?q=(_template:("b6c8c774b3064276834161457128d4d1") AND (display_name_t:(throat* can*) OR alias_t:(throat* can*))) AND _val_:__boost&start=0&rows=1000000&fl=*,score&fq=_indexname:(sitecore_web_index)&wt=xml

If I look up "17-H" i get this

?q=(_template:("b6c8c774b3064276834161457128d4d1") AND (display_name_t:(17* H*) OR alias_t:(17* H*))) AND _val_:__boost&start=0&rows=1000000&fl=*,score&fq=_indexname:(sitecore_web_index)&wt=xml

If I plug that directly into SOLR and change the display_name_t and alias_t to look for ("throat can*") or ("17-H") it returns what I would expect.

I'm hoping there is a way to adjust the translation of the LINQ StartsWith query to not tokenize based on dashes or spaces.

1 Answer 1


You can set indexType as UNTOKENIZED which means "Phrases will be stored as a whole – the entire value of the field, essentially" so it will consider 17-H as a single word instead of break into different words. You can do like below:

<field fieldName="displayname" storageType="YES" indexType="UNTOKENIZED" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.