EPiServer  /  Find October 12, 2011

First version of the Truffler EPiServer CMS integration

Today we’re releasing a first, early version of the Truffler integration for EPiServer CMS. This version contains the essential parts for automatically indexing PageData objects and querying them. There’s quite a lot of work remaining before we’re near as feature complete as we would like to be, but this version should contain the essentials for development.

We’ll be adding documentation and a lot more functionality over the coming days and weeks, but we wanted to get it out there as quickly as possible so that we could get some feedback. So, please create yourself a Truffler index if you haven’t already and try it out :)


The integration, which is shipped along with the download package for the regular .NET API contains two assemblies, both of which should be referenced. Features included are:

  • A singleton class named EPiSearchClient. This should be used when searching for EPiServer entities (currently PageData but in the future files in VPPs, Community entities etc). It will use the same configuration as the Client.CreateFromConfig method.
  • A module that will handle automatic indexing of pages as they are published.
  • A scheduled job for doing a full reindexing of the site.
  • An extension method named GetPagesResult that can be used on search queries (example below). This method will retrieve only the PageReferences for matching pages and fetch the actual pages using the DataFactory.GetPages method. If PageTypeBuilder is used the returned pages will be returned as the correct type. This method will also cache the result with a dependency to EPiServer’s master cache key.
  • An extension method named Match for filtering on PageReferences.

Querying pages

A simple example of searching for pages and retrieving the actual PageData objects can look like this:

var pages = EPiSearchClient.Instance.Search<NewsitemPageType>()
    .Filter(x => x.Author.Match("John"))
    .OrderByDescending(x => x.StartPublish)

Note that with the above code the result will be actual PageData objects and that the query will be cached. The cache will be released if any page on the site is changed.


The above example, using GetPagesResult is suitable for querying scenarios where we’d otherwise had used FindPagesWithCriteria. We can of course also use the Select method to project matching pages to a different type, including highlights etc.

    .Select(x => new { 
        Content = x.MainBody.AsHighlighted()})

Naturally, no matter if we’re using the GetPagesResult method to get actual PageData objects or projecting to something else we can use cool features such as geo search and boosting, as well as facets.

Excluded and included fields

We exclude a number of properties (like IsReadOnly) when serializing PageData objects but also include a few extension methods, for instance the RolesWithAccess method which we can use to filter matched pages for read access rights for a certain group (in a rather crude way at the moment).

    .For("Possibly secret stuff")
    .Filter(x => x.RolesWithReadAccess().Match("Everyone"))

Feedback, please?

Like I wrote above, please keep in mind that this is an early version and that we will be ever so grateful for any feedback that you give us! Of course much more information and documentation, as well as a NuGet package is coming.

We’re also interested in hearing from you what we should prioritize next. Currently two things that we see as important is indexing files in VPPs and re-indexing pages when their ACL changes.

PS. For updates about new posts, sites I find useful and the occasional rant you can follow me on Twitter. You are also most welcome to subscribe to the RSS-feed.

Joel Abrahamsson

Joel Abrahamsson

I'm a passionate web developer and systems architect living in Stockholm, Sweden. I work as CTO for a large media site and enjoy developing with all technologies, especially .NET, Node.js, and ElasticSearch. Read more


comments powered by Disqus

My book

Want a structured way to learn EPiServer 7 development? Check out my book on Leanpub!

More about EPiServer Find