Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
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.