Filtering search on folder path with Sitecore Contentsearch API

Using the new Sitecore contentsearch api allows you search against a lucene index with very little effort. Examples are a bit short on the ground but using Linq you can find yourself doing something like this to search for an item by name, somewhere within a folder structure:

Context.GetQueryable().Where(i =>
i.Name == searchTerm &&

This may well work. However you may also run into a Lucene error stating that you are using too many clauses, the maximum being limited by default to 1024.

Puzzling as we have only defined two clauses. The underlying reason is that string.StartsWith() or .Contains() or .EndsWith() are all mapped to the lucene SpanWildcardQuery type by the Api. Within Lucene itself this is them expanded to thousands of Boolean queries that, in a round-about way, fullfill the string filter. Depending on your content this can be expanded to more than 1024 boolean clauses just for this simple search and this hits the limit defined in .config. Incidently this config setting does not work insofar as the value is not read but the default value is the same as that contained in config.  A work-around is therefore required if you wish to  increase this limit.

If you raise the clause limit high enough your query should work and you’ll get your result, albeit with a performance hit. This  post is specifically about filtering your search within a folderPath and as such if you’re filtering using the SearchResultItem.Path string property you’re doing it wrong!

Instead, cast your eye to the SearchResultItem.Paths property – an array containing the id of every parent folder for the item. Using Paths.Contains(folderId) achieves the same result Path.StartsWith(“\some\folder\tree\”)  but does so without any wildcard queries and is drastically quicker.


Posted in, C#, Sitecore, Sitecore 7, Sitecore 8 | Tagged , , | Leave a comment

Sitecore – Data at the root level is invalid

This gallery contains 1 photo.

This XmlException can occur within a  Sitecore site where a general link field contains just plain text, for example a template flipped from link field to text field or just editing in raw. Clear the field and re-populate with a … Continue reading

More Galleries | Leave a comment

QoS setup with Draytek 2920n router using DSCP packet header for low priority backup traffic.

In short I spent far too long figuring out how to do this not share it. Running an online backup service (Crashplan) on my laptop was killing my network for everything else that was using it. I documented in a … Continue reading

More Galleries | 5 Comments

De-prioritizing CrashPlan upload traffic with DSCP/TOS and QoS on Windows 7

Edit: See this post for a working practical config with a router that uses these settings.

Update 2013-05-30: The solution described at the end of this post is applicable to Windows 7 Professional and other non-‘home’ editions. Windows 7 Home Editions do not appear to have group policy editor (gpedit.msc) installed as standard.

I spent a fair amount of time trying to get to the bottom of this and so thought I would share my experiences, and partial successes. This post describes the issues I had trying to stop Crashplan’s upload traffic slowing down everything else on the network while utilising the available bandwidth for very large uploads. It talks about Differentiated Services Code Point or DSCP, QoS, Netmon packet monitor, Group Policy settings, and various unsuccessful fixes to the problem of Crashplans DSCP setting having no apparent effect either due to a bug or limitations of Windows 7. This post doesn’t discuss router configuration (to be part of a separate post), just Crashplan and DSCP on Windows 7.

Continue reading

Posted in Networking, Windows | Tagged , , , , , , | 14 Comments

Redirect Manager module for Sitecore, updated on Codeplex

Still much tidying up to do, but a working v0.5 alpha release now up on Codeplex Please report any bugs or issues via Codeplex. Fixes broken language prefix handling. Also includes multiple breaking changes since previous v0.4 release in SQL … Continue reading

More Galleries | 1 Comment

Updated database script for shared source ‘Redirect Manager’ module.

EDIT: 2012-May-24 This project has now moved to

A quick update: The currently available blank database must be attached via Sql2008 R2 instance or later. For earlier versions there is now a revised SQL create script.
Continue reading

Posted in Sitecore, Sitecore 6, SQL Server 2005, Web development and programming | Leave a comment

Sitecore ‘Redirect Manager’ module available on shared source.

A quick post to say that I’ve finally uploaded my shared source ‘Redirect Manager’ module to
Continue reading

Posted in, C#, Sitecore, Sitecore 6 | 30 Comments

Sitecore LinkManager – Out of context link generation

This is part 2 of 2 posts on detailed Sitecore.Linkmanager configuration.
Continue reading

Posted in, C#, Sitecore, Web development and programming | Tagged , | 1 Comment

Sitecore LinkManager – Multi-site configuration

Urls for sitecore items are generated by the static class Sitecore.Links.LinkManager. In normal use you wont have any issues, but things can get trickier when you step out of a simple scenario.
Continue reading

Posted in, Sitecore, Web development and programming | Tagged , | 1 Comment

Moved from to self-hosted WordPress.

I’ve had a blog hosted, mostly free, on for a while. I soon found that the ability to paste code, XML or HTML was severely limited by clean-up functions that would strip-out the data whenever I saved or switched between ‘Visual’ and ‘HTML’ views. Continue reading

Posted in Sitecore, Web development and programming | Tagged , | Leave a comment