Philip EliassonWriting about Episerver, .Net and web development
  • Start page
  • About me

Removing CreatedBy and UpdatedBy from Episerver Find index

2017-07-06 0 comments Article Episerver CMS, Episerver Find

I found out of a coincidence that I could search on  the web editors name and get all pages they had created and updated.

This is a behavior that I did not want and I thought it was just to disable these fields from indexing in the Initialization module for the find functionality but I was mistaken.

It was no problem to remove the fields from the page data by adding this code to the Initialization module:

SearchClient.Instance.Conventions.ForInstancesOf<SolutionPageData>()
    .ExcludeField(x => x.CreatedBy)
    .ExcludeField(x => x.ChangedBy);

The problem comes when you have enabled indexing on content areas on pages. Blocks in content areas seems to magically get properties like CreatedBy and UpdatedBy when they gets indexed with a page. Blocks does not even have these properties in base model but in Find index they do.

I solved this problem by adding the properties CreatedBy and UpdatedBy in my SolutionBlockData class:

[Ignore]
public string CreatedBy { get; set; }

[Ignore]
public string ChangedBy { get; set; }

And I also disabled indexing of these fields in the Initialization module:

SearchClient.Instance.Conventions.ForInstancesOf<SolutionBlockData>()
    .ExcludeField(x => x.CreatedBy)
    .ExcludeField(x => x.ChangedBy);

Happy coding 🙂

/Philip

Tags: CMS, Episerver, Find

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Swagger documentation of your apis in your solution
  • Automatic way to handle SVG icons with Episerver
  • Removing CreatedBy and UpdatedBy from Episerver Find index

Recent Comments

    Archives

    • October 2019
    • November 2017
    • July 2017

    Categories

    • Episerver CMS
    • Episerver Find
    • Uncategorized

    Copyright philipe.se 2017