How to index content from custom media provider

Vote:
 

Hi,

I've created a custom media provider, but the media files are not being indexed. Is there something I need to implement for this to work?

I'm using EpiFind version 12.4.3.0 and CMS version 10.10.4.0

#188638
Feb 28, 2018 10:45
Vote:
 

I think you will likely have to add an implementation of IReindexInformation to let Find know about your provider (or the "root" that matters)

[ServiceConfiguration(typeof (IReindexInformation), Lifecycle = ServiceInstanceScope.Singleton)]
public class MediaReIndexInformation : IReindexInformation

#188641
Feb 28, 2018 11:25
Vote:
 

That was a pretty hidden interface @Quan.
Do you have any examples and documentation on how and when to use it?

#188645
Feb 28, 2018 13:49
Vote:
 

Not very hidden per se https://world.episerver.com/documentation/Class-library/?documentId=find/8/29B47DBE

I don't have any implementation at hand, but basically you return a Root, and a collection of ReindexTarget so Find now what to index.

For example (pseudo code)

public virtual ContentReference Root
{
get { return _referenceConverter.GetRootLink(); }
}

public virtual IEnumerable<ReindexTarget> ReindexTargets
{
get
{
var catalogs = GetCatalogs();
foreach (var catalogContent in catalogs)
{
var reindexTarget = new ReindexTarget
{
ContentLinks = GetDescendents(catalogContent.ContentLink),
Languages = catalogContent.ExistingLanguages,
SiteDefinition = SiteDefinition.Empty
};

yield return reindexTarget;
}
}
}



#188646
Edited, Feb 28, 2018 13:55
Vote:
 

Quan, I meant hidden since there is no documentation of it here:
https://world.episerver.com/documentation/developer-guides/find/

#188662
Feb 28, 2018 16:06
Vote:
 

So I did the implementation of ReIndexInformation and now when I run EPiServer Find Content Indexing Job, the media that I want to index is returned from method ReindexTargets but it's not indexed and no other items either which it did before...

I just wanted to add more content to be indexed not state all content that should be indexed.

Perhaps the solution is to add something in my EPiServerFindInitializationModule?

-The above didn't occur again after I runned the Indexing Job without the code for ReindexInformation and then runned it again with the code. I added so I return languages also, not just contentlinks but I get this error:

ERROR EPiServer.Find.Cms.ContentIndexer: An exception occurred while fetching content. Object reference not set to an instance of an object..
System.NullReferenceException: Object reference not set to an instance of an object.
   at EPiServer.Find.Cms.ContentIndexer.<>c__DisplayClass51_1.<ReIndex>b__1(IEnumerable`1 currentBatch, ParallelLoopState loopstate)

ERROR EPiServer.Find.Cms.CmsUnifiedSearchSetUp: IAttachmentHelper can not be initiated.

Any ideas?

#188711
Edited, Mar 01, 2018 13:50
Vote:
 

Can you share your code here, Angelica?

#188749
Mar 02, 2018 7:39
Vote:
 

Document inherits GenericMedia which inherit MediaData

StartPublish date is set on the Document. But in edit mode it says Not published yet. Don't know if that has any affect.

In the Provider LoadContent:

     var routable = content as IRoutable;
            if (routable != null)
            {
                routable.RouteSegment = UrlSegmentGenerator.Service.Create(content.Name);
            }

            var securable = content as IContentSecurable;
            securable.GetContentSecurityDescriptor().AddEntry(new AccessControlEntry(EveryoneRole.RoleName, AccessLevel.Read));

            var versionable = content as IVersionable;
            if (versionable != null)
            {
                versionable.Status = VersionStatus.Published;
                versionable.IsPendingPublish = false;
            }

            var changeTrackable = content as IChangeTrackable;
            if (changeTrackable != null)
            {
                changeTrackable.Changed = DateTime.Now;
           }

In ReIndexInformation:


IEnumerable<ReindexTarget> IReindexInformation.ReindexTargets
{
            get
            {
                //Only index documents that is linked to
                var mappedIdentities = IdentityMappingService.Service.List(Provider.ProviderKey);
                var contentSoftLinkRepository = ServiceLocator.Current.GetInstance<IContentSoftLinkRepository>();
                var contentLinks = new List<ContentReference>();
                var languages = new List<CultureInfo>();

                foreach (var mappedItem in mappedIdentities)
                {
                    var resource = new DocumentPortalResource(mappedItem);

                    if (resource.ModelType == typeof(Document))
                    {
                        var softLinks = contentSoftLinkRepository.Load(resource.ContentLink, true);
                        if (softLinks.Any())
                        {
                            contentLinks.AddRange(softLinks.Select(x => x.ReferencedContentLink));
                            foreach (var refLang in softLinks.Select(x => x.ReferencedLanguage).Distinct())
                            {
                                if (!languages.Contains(refLang))
                                {
                                    languages.Add(refLang);
                                }
                            }

                        }
                    }

                }

                var result = new List<ReindexTarget>()
                {
                    new ReindexTarget() { ContentLinks = contentLinks, Languages = languages }
                };

                return result;
            }
}

#188763
Edited, Mar 02, 2018 11:52
Vote:
 

Just to be sure, contentLinks and languages contain the information you need, right? 

You probably want to add this                         SiteDefinition = SiteDefinition.Empty

#188765
Mar 02, 2018 12:01
Vote:
 

Yes, the contentLinks and languages contain the information that I want.

I will add SiteDefinition and test again.

#188766
Mar 02, 2018 12:21
Vote:
 

I still get the same error in the log file.

Something that needs to be implemented in the provider perhaps?

The content folders in my content provider is indexed and that isn't something that I return in reindexinformation. If it doesn't use the Root in some way that I don't control.

#188767
Edited, Mar 02, 2018 12:47
Vote:
 

If you drop this file https://www.dropbox.com/s/1irocvoltniq89h/EPiServer.Find.Cms.pdb?dl=0 and https://www.dropbox.com/s/2r8qx94pfjr08o2/EPiServer.Find.pdb?dl=0 

Into your bin folder and rerun the code, would it display the line in the exception stacktrace? 

#188771
Mar 02, 2018 14:05
Vote:
 

Hi,

I didn't get any more information about the error, but I suspect that perhaps it is the languages that sometimes seems to return null.

I removed the reindexinformation implementation -> cleaned index -> run reindex job and now for some reason the content is indexed in the custom content provider.

#188896
Mar 06, 2018 14:33
Vote:
 

I think I have a similar problem. I have implemented a custom ContentProvider from Alloy (source below). It is working fine, it is indexed when i run the find indexing job. But when update a source page Find does not reindex the cloned content. Anyone know how I can fix this?

https://github.com/episerver/AlloyDemoKit/blob/ea9ffd8b6c1884768284e256565ffe01c32e9aca/src/AlloyDemoKit/Business/ContentProviders/ClonedContentProvider.cs

#190624
Apr 13, 2018 11:26
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.