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 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)
.GetPagesResult();
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.
EPiSearchClient.Instance.Search<StartpagePageType>()
.For("Truffler")
.Select(x => new {
x.PageName,
x.LinkURL,
Content = x.MainBody.AsHighlighted()})
.GetResult();
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.
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).
EPiSearchClient.Instance.Search<StandardPage>()
.For("Possibly secret stuff")
.Filter(x => x.RolesWithReadAccess().Match("Everyone"))
.GetPagesResult();
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.
This blog is built with EPiServer Community, EPiServer CMS, ASP.NET MVC and a bunch of other great products. The source code is available for download at the projects page, where you also can read more about this site and my other projects.
read more
Comments
Igor 7 months ago
Hi, Joel! I'm sure you have done great job and I hope that Truffler will receive many accolades among the EPi community. One question about automatic indexing...Which types of properties can be automatically indexed with Truffler extension for EPiServer? Of course, there no problems for indexing "simple" types like int, string, bool, DateTime, etc. But what if I have custom property type with custom underlying class that has some fields or I have some property type that inherits from other property type and serializes his value to xml or may be json format and I don't want index it as xml/json? Is it possible to index PageData object with such properties? Has Truffler native support for indexing custom types? If not, could it be possible to override Index() method to add my own logic for indexing? Or may be I just should realize ToString() method in my custom type or something else...
Joel Abrahamsson 7 months ago
Hi Igor!
If you're using Page Type Builder and exposing the property as some complex object it will be serialized as that object. For instance, say you have a class named Author with Name and Email properties and you have a page type property such as
[PageTypeProperty(Type=typeof(PropertyAuthor))] public Author Author { get; set;}Then you can do:
EPiSearchClient.Instance.Search() .Filter(x => x.Author.Name.Match("Joe");You can also customize how the Author type is indexed. See http://truffler.net/Documentation/dotnet-api-customizing-serialization for more information on that.
If you aren't using Page Type Builder, or want to index something else then you can create an extension method that retrieves the value from the PageData object and configure the client to index that, see http://truffler.net/Documentation/dotnet-api-including-fields
Does that answer your question?
Joel Abrahamsson 7 months ago
I should add that modifying the conventions should be done during application_start at the moment. We might add some special hook for that in the future, but doing it that way should work.
Igor 7 months ago
Yes, thank you, this is exactly what I wanted to know. And ability to include additional fields is very cool feature :-)
Johan Kronberg 7 months ago
Looks great! Maybe it's been mentioned elsewhere (?) but it would be interesting to see your ideas of adding an altered EPiServer URL's rendered HTML to the index and/or build a index by crawling.
Joel Abrahamsson 7 months ago
Thanks Johan!
We've been thinking a bit about that and we'll see if we can work out some elegant solution. It could be done quite easily in a crude way though by creating an extension method that makes a HttpWebRequest to the URL and map that method for indexing along with the PageData object.
jamie 6 months ago
This is an excellent information forever. You have provided very valuable information here.