Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

EPiFind - how to index additional fields



I'm working with EPiFind 10 and EPiServer CMS 9. I need to display a list of events filtered by county.

My EventPage looks like this:

[ContentType(GUID = "904c87fe-e0ba-4245-9f8c-1f8e9aaf4094")]
public class EventPage : PageData
    [SelectOne(SelectionFactoryType = typeof(CountySelectionFactory))]
    public virtual PageReference County { get; set; }

And search logic w/o filtering:

var events = SearchClient.Instance.Search()
                            .OrderBy(x => x.DateAndTime)
                            .Skip((pageNumber - 1) * pageSize)

During indexing, I would like to index a county name (page name of County page type that is referenced by EventPage), and filter events by that field.

When the editor renames the county page, I would like update the search index and all documents of type EventPage (or my custom document) that have

County = renamedPage.PageLink

I basically need something like , but for EPiFind 10.

Should I let EPiFind index EventPage(s) as usual, and explicitly index documents that are optimized for search:

How can I execute bulk update? Can I use NewCommand for that?

Any help would be greatly appreciated!

Sep 28, 2015 15:30

I would add a new readonly property called CountryName to your EventPage that's a string representing the country name (lazy load the country name as it will only be accessed when the EventPage is indexed by Find). Makes it real simple to search and facet on the country when searching events. 

Then I'd add a ContentUpdating event handler for your County page, use Find to look for all events in that country and update the related event pages.

Given I guess the countries are not renamed too often performance shouldn't be a big issue?


Sep 28, 2015 22:03

I asked a simular question a while ago and use the answer I got a lot and it works great. Read more here:

In summary it says that you should create a extension method for the pagetype and a function in it to pick up county name, then in a initialization module add something like this:

    .IncludeField(x => x.CountyName());

This makes that Find will add a new property named CountyName to the object and it will only access it when indexing.

Later you can do terms filtering och things like that on it

Sep 29, 2015 9:24

Thank you guys! Extension method works like a charm :)

I need help with update method.

Init module:

private void ContentEvents_PublishedContent(object sender, EPiServer.ContentEventArgs e)
    var countyPage = e.Content as CountyPage;
    if (countyPage != null)
        var eventPages = SearchClient.Instance.Search<EventPage>()
                                        .Filter(x => x.County.Match(countyPage.PageLink))
                                        // return any field
                                        .Select(x => x.PageLink)

        foreach (var searchHit in eventPages.Hits)
                        .Field(x => x.CountyName(), countyPage.Name)

1. Can I update EventPage(s) in one go, or do I have to update them one by one?

2. The above code throws the following exception:

An exception of type 'EPiServer.Find.ServiceException' occurred in EPiServer.Find.dll but was not handled in user code

Additional information: The remote server returned an error: (403) Forbidden.

Your key is not authorized to access (POST) '/INDEX_NAME/Models_Pages_EventPage/_700f7047-ce29-456d-9403-af5d6205584e_no/_update'


Sep 29, 2015 11:42

If you are using Update, I think you need to do them one by one. 
It would be better to just index a batch of EventPages

Sep 29, 2015 11:55
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.