EPiServer Full Text Search Product Integration

Product version:

EPiServer Framework 6.1 / 6.2

Document last saved:

 

EPiServer Community Integration

EPiServer.Community.Search is a new module in EPiServer Community 4 that contains classes for the integration with the EPiServer FTS Client. Most notably are the SearchModule class and the SearchHandler class. The SearchModule is responsible for subscribing and unsubscribing to Add, Update and Remove events fired by the FrameworkFactoryBase class while the SearchHandler is responsible for converting a Community entity to an IndexRequestItem and calling the UpdateIndex method in the FTS Client. The SearchHandler is, as all handlers in the Community API, a singleton with an Instance set property. Notable virtual methods in the SearchHandler are:

public virtual void ConvertEntityToIndexItem(IEntity entity, IndexRequestItem item)

This is the main method for converting a Community IEntity to an IndexRequestItem. This method will in turn call the following methods to set various properties to the IndexRequestItem before returning.

  • protected virtual void AddReferenceIdToIndexItem(IEntity entity, IndexRequestItem item)
    Adds the default “parent” UniqueID as the ReferenceId to the passed item for entities of type:
     
    IComment –> CommentedEntity
    EPiServer.Community.Forum.Reply -> EPiServer.Community.Forum.Topic
    EPiServer.Community.Blog.EntryComment -> EPiServer.Community.Blog.Entry
    EPiServer.Community.ImageGallery.ImageComment -> EPiServer.Community.ImageGallery.Image
    EPiServer.Community.VideoGallery.VideoComment -> EPiServer.Community.VideoGallery.Video
    EPiServer.Community.Contest.Question -> EPiServer.Community.Contest.Contest
     
    See the ReferenceId section on how setting a reference id will affect search results.
     
  • protected virtual void AddUriToIndexItem(IEntity entity, IndexRequestItem item)
    Sets the item.Uri using the configured uri provider if specified in the Community Search Section or the default uri provider.
     
  • protected virtual void AddCultureToIndexItem(ILocalized entity, IndexRequestItem item)
    Adds the entity.LanguageID to the item.Culture if the entity is ILocalized.
     
  • protected virtual void AddContentDataToIndexItem(IContent contentEntity, IndexRequestItem item)
    Adds IContent data to the IndexRequestItem if the entity is  IContent.
     
    contentEntity.Header -> item.Title
    contentEntity.Body -> item.Displaytext
    contentEntity.Created -> item.Created
    contentEntity.Modified -> item.Modified
    contentEntity.Author.Name -> item.Authors
     
  • protected virtual void AddUserDataToIndexItem(IUser user, IndexRequestItem item)
    Adds IUser data to the IndexRequestItem if the entity is IUser.
     
    user.Alias -> item.Title
    user.GivenName + “ “ user.SurName -> item.DisplayText
    user.CreatedDate -> item.Created
    user.CreatedDate -> item.Modified
     
  • protected virtual void AddAttributesToIndexItem(IAttributeExtendableEntity attributeExtendableEntity, IndexRequestItem item)
    Adds all dynamic attributes of type string to item.Metadata.
     
  • protected virtual void AddDocumentDataUriToIndexItem(Document documentEntity, IndexRequestItem item)
    new Uri(documentEntity.PhysicalPath) -> item.DataUri
     
  • protected virtual void AddCategoriesToIndexItem(ICategorizableEntity categorizableEntity, IndexRequestItem item)
    Adds all Community entity categories recursively to item.Categories.
     
  • protected virtual void AddForumToIndexItem(Forum.Forum forumEntity, IndexRequestItem item)
    forumEntity.Name -> item.Title
     
  • protected virtual void AddExpertToIndexItem(ExpertBase expertEntity, IndexRequestItem item)
    expertEntity GivenName and SurName -> item.Title
    expertEntity Description and Qualifications -> item.DisplayText
     
  • protected virtual void AddExpertAnswerToIndexItem(EPiServer.Community.Expert.Answer expertAnswer, IndexRequestItem item)
    item.Title = expertAnswer.Header;
    item.DisplayText = expertAnswer.Body;
    item.Created = expertAnswer.Created;
  • protected virtual void AddCalendarToIndexItem(Calendar.Calendar calendarEntity, IndexRequestItem item)
    item.Title = calendarEntity.Name;
  • protected virtual void AddEntityReadAccessToIndexItem(ISecurableEntity entity, IndexRequestItem item)
    Adds users with read access to the entity based on EntitySecurityHandler.Instance.GetUsers(entity) and EntitySecurityHandler.Instance.GetGroups(entity). Users are added to the item.AccessControlList by UniqueID while groups are added by their name. Note that this means that changing a group name will probably require a total re-index.
  • protected virtual void AddVirtualPathToIndexItem(IEntity entity, IndexRequestItem item)
    Chains fixed relations to a VirtualPath (e.g. Forum -> Room -> Topic -> Reply).
     
  • protected virtual void AddEntityStatusToIndexItem(FrameworkEntityStatusBase entity, IndexRequestItem item)
    Adds a category to the item using the Status enum value.

Queries 

EPiServer Community contains two query types that helps you to create queries based on EPiServer Community Entities. Both query classes are located in the EPiServer.Community.Search.Query namespace.

  • EntityTypeQuery(Type type)
    Queries an index for Entities of a specific type.
  • EntityVirtualPathQuery(IEntity entity)
    Inherits from VirtualPathQuery, automatically sets the VirtualPathNodes property to match that of the passed entity. For example, if you pass an entity of type Blog to the constructor the search will be limited to sub types of Blog - like blog entries and blog comments.

Configuration

The search element in the EPiServer.Community configuration section contains a collection of supported types. Only the community types specified here will be indexed. You may also set the default namedIndex and/or named indexing service to use by specifying defaultNamedIndex and defaultNamedIndexingService attributes for the search element.

Bulk Indexing

Community entities can be added to the index in bulk by calling the following method in the EPiServer.Community.Search.SearchHandler:

AddCommunityEntitiesToIndex(Type type, bool overwrite)
This will fetch all entities for the specified type (or all entities if null is passed) and update the index for each one. The overwrite parameter specifies whether any existing index item (same Id) should be overwritten or not.

EPiServer CMS Integration

The EPiServer Full Text Search Service is available as a standalone download for EPiServer CMS websites.

EPiServer Relate Integration

The CmsIntegrationModule event handler section has been extended to call the new CmsSearchHandler class when pages are published or removed. The CmsSearchHandler is responsible for converting a PageData object to a IndexRequestItem which is done in the virtual method ConvertPageDataToIndexItem The method calls in turn the following virtual methods:

  • AddPageUriToIndexItem(page, item);
    Sets the item.Uri to PageData object LinkURL
  • AddPageMetaDataToIndexItem(page, item);
    item.Title = page.PageName;
    item.Created = page.Created;
    item.Modified = page.Changed;
    item.Culture = page.LanguageID;
    item.ItemType = page.GetType().AssemblyQualifiedName;
     
  • AddPagePropertiesToIndexItem(page, item);
    Adds all string content in properties marked as searchable to item.DisplayText.
  • AddReadAccessToIndexItem(page, item);
    Converts the page.ACL to the item.AccessControlList
     
  • AddVirtualPathToIndexItem(page, item);
    Adds the page.PageGuid for all page nodes from root page to the passed page.
     
  • AddStatusCategoryToIndexItem(page, item);
    Adds a category with the value of the Community EntityStatus.Approved enum to the item

Queries

The Relate project has two custom query types used for closer integration with the Full Text Search functionality.

CmsFileVirtualPathQuery(UnifiedFile file)
Inherits VirtualPathQuery, automatically adds the nodes in the file path to the VirtualPathNodes property.

PageVirtualPathQuery(PageData page)
Inherits VirtualPathQuery, automatically adds nodes to the VirtualPathNodes property based on the passed page's location in the tree.

Related Information

See also the following: