Filter Dictionary using an Array in Find

Vote:
 

I have indexed YouTubeChannelInfo objects which contains many YouTube Channel information.

YouTubeChannelInfo has a Dictionary attribute called 'Playlists' which contains Playlist Title as the key and the ID as the value. Thus there could be many playlists for a given channel.

public class YouTubeChannelInfo
{

public string Name { get; set; } // Channel Name
public Dictionary<string, string> Playlists { get; set; } // Key - Playlist Title, Value - Playlist ID
}

I have string[] playlists which contains an array of playlist titles and need to filter only the YouTube Channels based on those playlist titles.

I have used


string[] playlists = GetPlaylists();

var result = client.Search<YouTubeChannelInfo>()
.Filter(v => playlists.Any(p => v.Playlists.ContainsKey(p)).Match(true))
.GetResult();

This returns 0 results. How do I filter only the YouTube channels which has at least one playlist title in the string[] playlists ?

#201844
Edited, Mar 05, 2019 10:46
Vote:
 

Hi Senura,

Have you looked into creating your own filter method: https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Filtering/Custom-filtering-methods/

You could possibly use the following on a complex object:

var searchQuery = client.Search<YouTubeChannelInfo>()
.Filter(x => x.Playlists.MatchContained(
a => a.Key, "Your Playlist Title"));

Have a look at the complex object filtering located here : https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Filtering/Complex-objects/

Thanks

Paul

#201848
Edited, Mar 05, 2019 12:07
* 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.