EnablePageFilesIndexing does not process ForInstancesOf<UnifiedFile>().ShouldIndex()

Vote:
 
FileIndexer.Instance.Conventions.ShouldIndexVPPConvention = new VisibleInFilemanagerVPPIndexingConvention();
ContentIndexer.Instance.Conventions.EnablePageFilesIndexing();
FileIndexer.Instance.Conventions.ForInstancesOf<UnifiedFile>().ShouldIndex(x => FileTypesToIndex.Contains(x.Extension));

FileTypesToIndex is a list of file file extensions similiar to the one in Joel's blog post http://joelabrahamsson.com/entry/building-a-search-page-for-an-episerver-7-site-with-episerver-find   

In this list I don't have .jpg. Still .jpg files from PageFiles are added to the Index and show up in UnifiedSearchFor.
What do I need to do in order to have the same ShouldIndex-check for PageFiles?

This project is EPi 7 and the latest version of the module.

#64684
Jan 07, 2013 10:43
Vote:
 

Hi,

The PageFiles handling is done by the ContentIndexer so in order to filter PageFiles you have to change the ContentIndexer conventions:

ContentIndexer.Instance.Conventions.ForInstancesOf<IContent>().ShouldIndexPageFile((content, file) => FileTypesToIndex.Contains(file.Extension));

/ Henrik

#64698
Jan 07, 2013 13:39
Vote:
 

Great! Thanks!

#64701
Jan 07, 2013 14:20
Vote:
 

Is it possible to have multiple Global ForInstancesOf? such as:

            PageIndexer.Instance.Conventions.ForInstancesOf<PageData>().ShouldIndex(page => page.PageTypeName.StartsWith("[ExtensionSys] Text"));
            PageIndexer.Instance.Conventions.ForInstancesOf<PageData>().ShouldIndex(page => page.PageTypeName.StartsWith("News - Article"));
            PageIndexer.Instance.Conventions.ForInstancesOf<PageData>().ShouldIndex(page => page.PageTypeName.StartsWith("Content Page - 3 Columns"));

    

#66506
Mar 03, 2013 19:58
Vote:
 

You can pass a full fledge delegate instead of a lambda expression:

PageIndexer.Instance.Conventions.ForInstancesOf<PageData>().ShouldIndex(page => 
{
return page.PageTypeName.StartsWith("[ExtensionSys] Text") || page.PageTypeName.StartsWith("News - Article") || page.PageTypeName.StartsWith("Content Page - 3 Columns"; });

    

#66508
Edited, Mar 04, 2013 0:55
Vote:
 

Great, that sounds good - Im getting the actual Composer name from the Search such as CF__1218_8296_4521_12887, is there a way to get the actual Page where it is referenced so the user can click through to the page and for FIND to show the Excerpt too?

#66519
Mar 04, 2013 9:50
Vote:
 

I have tried tried with following code in my Global.asax.cs file but I still get  jpg-files from page files

            ContentIndexer.Instance.Conventions.EnablePageFilesIndexing();
            ContentIndexer.Instance.Conventions.ForInstancesOf<SitePageData>().ShouldIndexPageFile((content, file) => FileTypesToIndex.Contains(file.Extension));

where

        private static readonly IList<string> FileTypesToIndex = new List<string>
            {
                ".doc",
                ".docx",
                ".pdf",
                ".txt",
                ".xls",
                ".xlsx"
            };

What am I missing? (EPiServer 7)

#113769
Nov 27, 2014 14:24
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.