Filtering by contentreferences in contentarea

Vote:
 

We have a property RelatedPages that is of type ContentArea and exists on all pages. The property is used to drag'n drop related pages.

We like to use EPiServer Find to filter out pages that has is related to the current page.

I.e

var searchResults = SearchClient.Instance.Search()
.Filter(
(x => x.RelatedPages.Items.MatchContained(z => z.ContentLink.ID, currentPage.PageLink.ID)))
.GetContentResult();

This does not yield any results...

We have also tried this without luck:
var searchResults = SearchClient.Instance.Search()
.Filter(
(x => x.RelatedPages.Items.Select(y => y.ContentLink.ID).Match(currentPage.PageLink.ID)))
.GetContentResult();

Any clues what could be wrong?

We have decorated the base class for pages SitePageData with [IndexInContentAreas].

#113929
Dec 01, 2014 17:37
Vote:
 

Hi!

Did you solve this problem?

/ Henric

#121406
May 08, 2015 16:06
Vote:
 

This should do the trick:

var searchResults = SearchClient.Instance.Search<SitePageData>()
                    .Filter(x => x.RelatedPages.ReferencedPermanentLinkIds.Match(currentPage.ContentGuid))
                    .GetContentResult();
#131883
Aug 07, 2015 14:46
Vote:
 

Thanks Mari! Old post, but helped me with my filtering issue today :)

#173121
Dec 14, 2016 16:34
Vote:
 

I have a similar issue although I have a Generic List of Content References and cant seem to get Find to return me results i have tried the following 

searchContext = searchContext.Filter(x => x.Authors.Select(y => y.ID) .Match(author.Value)); 

#184776
Nov 03, 2017 11:34