Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Filtering issue

Vote:
 

Hi! 

I've just started using Episerver Find and having trouble understanding how it works.

I'm trying to filter RoomPages by their availability status.  

This is my code: 

 var results = query.Client.Search()
                .FilterFacet("test", x => _contentRepository.Get(x.PageLink).IsClosed())
                .GetPagesResult();

And my extension method looks like this: 

 public static FilterExpression IsClosed(this RoomPage room)
        {
            return new FilterExpression(
                x => x.AvailabilityStatus.Match(Rooms.Status.Closed));
        }

This Match(Rooms.Status.Closed) does'nt seem to work since it returns Roompages with availability status open as well. 

Can someone enlighten me in what I'm doing wrong or provide a better solution for achieving this. 

Thanks in advance

#123156
Jun 25, 2015 16:18
Vote:
 
 var r = query.Client.Search<RoomPage>()
.Filter(x => _contentRepository.Get<RoomPage>(x.PageLink).IsClosed())
.GetPagesResult();

While this returns 0 hits. 

#123159
Jun 25, 2015 16:28
Vote:
 

You shouldn't fetch the page again in the filter statement. It should work by just doing:

.Filter(x => x.AvailabilityStatus.Match(Rooms.Status.Closed))

/Henrik

#123183
Jun 26, 2015 8:23
* 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.