Don't miss out Virtual Happy Hour this Friday (April 26).
Try our conversational search powered by Generative AI!
AI OnAI Off
Don't miss out Virtual Happy Hour this Friday (April 26).
Similar code works for me:
var typeQuery = new ContentTypesQuery();
foreach (string type in SearchPage.ContentTypesCategories)
{
typeQuery.AddContentType(type);
}
var accessQuery = new AccessControlListQuery();
accessQuery.AddAclForUser(PrincipalInfo.Current, HttpContext.Current);
var query = new GroupQuery(LuceneOperator.AND);
query.QueryExpressions.Add(typeQuery);
query.QueryExpressions.Add(accessQuery);
query.QueryExpressions.Add(new FieldQuery(searchText));
Haha, sorry. Sure it was. But it's a really simple class.
using EPiServer.Search.Queries.Lucene;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class ContentTypesQuery : CollectionQueryBase
{
private readonly string AssemblyName;
public ContentTypesQuery()
: base("EPISERVER_SEARCH_TYPE", LuceneOperator.OR)
{
var assembly = this.GetType().Assembly;
AssemblyName = assembly.GetName().Name;
}
public void AddContentType(string name)
{
base.Items.Add(string.Format("{0},{1}", name, AssemblyName));
}
}
And the reason was that we wanted the editors to be able to chose which types that should be searchable.
I guess ContentQuery<SearchableSitePageData>() is implemented in a similar way.
Can't I use this?
where SearchableSitePageData is
and SitePageData inherits from PageData.