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
That was a pretty hidden interface @Quan.
Do you have any examples and documentation on how and when to use it?
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; } } }
Quan, I meant hidden since there is no documentation of it here:
https://world.episerver.com/documentation/developer-guides/find/
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?
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;
}
}
Just to be sure, contentLinks and languages contain the information you need, right?
You probably want to add this SiteDefinition = SiteDefinition.Empty
Yes, the contentLinks and languages contain the information that I want.
I will add SiteDefinition and test again.
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.
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?
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.
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?
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