Category Archives: Sitecore

Improve your sitecore log with realtime output and calling class

Sitecore uses the extensive log4net logging framework to handle the large volume of logging entries it generates. Sometimes vague log entries can leave you scratching around trying to find where they originated from. This post explores some simple steps to add useful detail to, and real-time viewing of, the Sitecore log.

Continue reading

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:

public void BadSearch(string searchTerm)
{
   var webIndex = ContentSearchManager.GetIndex("sitecore_web_index");
   using (var context = webIndex.CreateSearchContext())
   {
      var results = context.GetQueryable<SearchResultItem>().Where(i =>
         i.Name == searchTerm &&
         i.Path.StartsWith("sitecore/content/stuff/")); // don't do this!
   }
}

This may well work. However you may also run into a Lucene error stating that you are using too many clauses, the default limit is 1024.

Continue reading