Hello, I'm trying to search for MediaData that only exists on published pages. The pages can have many different kind of block areas with MediaData inside them. The requirement is that the MediaData itself does not have to be unpublished, only its parent page where it exists. My search query looks as follows
var FileQuery = SearchClient.Instance.Search()
.For(model.Query)
.WildCardQuery(wildtext, x => x.Name)
.CurrentlyPublished()
.PublishedInCurrentLanguage()
.FilterForVisitor()
.FilterOnReadAccess()
.Track()
.Take(model.FilesMaxResults);
This gives me hits from all assets folders.
Then I'm trying to see if the link have soft link, if that is the case get OwnerContentLink.
var contentResultFileHits = FileQuery.GetContentResult();
var repository = ServiceLocator.Current.GetInstance();
var linkRepository = ServiceLocator.Current.GetInstance();
var fileHits = contentResultFileHits
.Select(x => x)
.Where(x => linkRepository.Load(x.ContentLink, true)
.Where(link => link.SoftLinkType == ReferenceType.PageLinkReference && !ContentReference.IsNullOrEmpty(link.OwnerContentLink))
.Select(link => link.OwnerContentLink)
.Any(o => CheckPublished(repository, o)));
After that, check if the ContentReference is PageData, if so check start publish date, stop publish date and deleted. Otherwise call method again with parent link.
This doesn't seem to work very well on blocks as the parent link for the block container doesn't reference the page. How can I improve my search query to get required result?
Hello, I'm trying to search for MediaData that only exists on published pages. The pages can have many different kind of block areas with MediaData inside them. The requirement is that the MediaData itself does not have to be unpublished, only its parent page where it exists. My search query looks as follows
This gives me hits from all assets folders.
Then I'm trying to see if the link have soft link, if that is the case get OwnerContentLink.
After that, check if the ContentReference is PageData, if so check start publish date, stop publish date and deleted. Otherwise call method again with parent link.
This doesn't seem to work very well on blocks as the parent link for the block container doesn't reference the page. How can I improve my search query to get required result?