AI OnAI Off
Think you need to change the:
.Filter(y => y.SearchCategories.Match(
"5"
))
As the SearchCategories are a list over categories you can't use match.
In my solution I created my own filter and then added that to the query.
var catalogBuilder = SearchClient.Instance.BuildFilter<PageData>(); foreach (int category in input.Categories) catalogBuilder = catalogBuilder.Or(x => x.Category.Match(category)); query = query.Filter(catalogBuilder)
Thanks Petter.
But it turns out that SearchCategories has the category name not the id. Sooo
y.SearchCategories.Match("CategoryName"))
Works.
I found this out by looking in the find index in the admin view of the CMS (click the find tab)
Cheers
Hi
I'm trying to use unified search to filter the results based on category. I've got so far
var results = SearchClient.Instance.UnifiedSearchFor(searchDefinition.SearchTerm, Language.English) .Filter(x => x.MatchTypeHierarchy(typeof(ContentPageBase))) .Filter(y => y.SearchCategories.Match("5")) .Skip(searchDefinition.Page - 1) .Take(pageSize);
And the SeachCategories method is implemented on ContentBasePage as
[Ignore] public virtual IEnumerable<string> SearchCategories { get { return this.Category.Select(x => x.ToString()); } }
Bu tfind doesn't return any results even though I know that there is a page in category "5" (filter hardcoded for demo purposes). Can anyone spot what is going on. Also - I would like to peek into Searchcategories in the search results (in VS debug mode) to see what is there - but the property seems to be unavailable.
Really appreciate any help
Thanks